From: Jim Warner Date: Sat, 3 Dec 2016 10:05:06 +0000 (-0600) Subject: ps: provide 'namespace' protection for 32-bit compiles X-Git-Tag: v3.3.13rc1~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c41c614b0c038d9374191f545259d9d70c451316;p=procps-ng ps: provide 'namespace' protection for 32-bit compiles This patch ensures that namespace output will look the same whether ps is built under a 32 or a 64-bit model. [ it would have been easier to change that library's ] [ data type, but we'll avoid breaking that ABI again ] Signed-off-by: Jim Warner --- diff --git a/ps/output.c b/ps/output.c index 62b23c19..8c6a5289 100644 --- a/ps/output.c +++ b/ps/output.c @@ -147,8 +147,8 @@ static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \ #define CMP_NS(NAME, ID) \ static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \ - if (P->ns[ID] < Q->ns[ID]) return -1; \ - if (P->ns[ID] > Q->ns[ID]) return 1; \ + if ((unsigned long)P->ns[ID] < (unsigned long)Q->ns[ID]) return -1; \ + if ((unsigned long)P->ns[ID] > (unsigned long)Q->ns[ID]) return 1; \ return 0; \ } @@ -1236,7 +1236,7 @@ static int pr_sd_slice(char *restrict const outbuf, const proc_t *restrict const #define _pr_ns(NAME, ID)\ static int pr_##NAME(char *restrict const outbuf, const proc_t *restrict const pp) {\ if (pp->ns[ID])\ - return snprintf(outbuf, COLWID, "%li", pp->ns[ID]);\ + return snprintf(outbuf, COLWID, "%lu", (unsigned long)pp->ns[ID]);\ else\ return snprintf(outbuf, COLWID, "-");\ }