From a0366fde4cadbdce03540c683611587dbcfb3c48 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 14 Oct 2021 13:28:05 +0100 Subject: ash: silence compiler warnings On 64-bit systems mingw-w64 defines pid_t as a 64-bit integer so some printf calls caused compiler warnings. --- include/libbb.h | 6 ++++++ shell/ash.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 098619305..9aff42e67 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -295,6 +295,12 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN #define LL_FMT "ll" #endif +#if ENABLE_PLATFORM_MINGW32 && defined(_WIN64) +#define PID_FMT "I64" +#else +#define PID_FMT +#endif + /* Large file support */ /* Note that CONFIG_LFS=y forces bbox to be built with all common ops * (stat, lseek etc) mapped to "largefile" variants by libc. diff --git a/shell/ash.c b/shell/ash.c index 98da20f8a..f211df83a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5070,7 +5070,7 @@ showjob(struct job *jp, int mode) if (mode & SHOW_ONLY_PGID) { /* jobs -p */ /* just output process (group) id of pipeline */ - fprintf(out, "%d\n", ps->ps_pid); + fprintf(out, "%"PID_FMT"d\n", ps->ps_pid); return; } @@ -5083,7 +5083,7 @@ showjob(struct job *jp, int mode) s[col - 3] = '-'; if (mode & SHOW_PIDS) - col += fmtstr(s + col, 16, "%d ", ps->ps_pid); + col += fmtstr(s + col, 16, "%"PID_FMT"d ", ps->ps_pid); psend = ps + jp->nprocs; @@ -5114,7 +5114,7 @@ showjob(struct job *jp, int mode) s[0] = '\0'; col = 33; if (mode & SHOW_PIDS) - col = fmtstr(s, 48, "\n%*c%d ", indent_col, ' ', ps->ps_pid) - 1; + col = fmtstr(s, 48, "\n%*c%"PID_FMT"d ", indent_col, ' ', ps->ps_pid) - 1; start: #if ENABLE_PLATFORM_POSIX || JOBS_WIN32 fprintf(out, "%s%*c%s%s", -- cgit v1.2.3-55-g6feb