]> granicus.if.org Git - procps-ng/commitdiff
ps: Output of nwchan is a number
authorCraig Small <csmall@enc.com.au>
Thu, 12 May 2016 10:43:49 +0000 (20:43 +1000)
committerCraig Small <csmall@enc.com.au>
Thu, 12 May 2016 10:43:49 +0000 (20:43 +1000)
For some time with enough compilier flags I have watched the
following warning drift by:
ps/output.c: In function ‘pr_nwchan’:
ps/output.c:658:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   return snprintf(outbuf, COLWID, "%x", (unsigned)rSv(WCHAN_NAME, str, pp));

nwchan is supposed to be the address of where the process is sleeping,
not the name. Besides %x is a hex number not a string hence the warning.

nwchan now prints the address, in hex and GCC is happy.

ps/output.c

index a8907088fbf2fdc527c4908e71d86004dbcc7852..5bc93f8ab24e1c1eee2d5d9f67a3cd1db7766088 100644 (file)
@@ -654,8 +654,12 @@ setREL1(WCHAN_NAME)
 }
 
 static int pr_nwchan(char *restrict const outbuf, const proc_t *restrict const pp){
-setREL1(WCHAN_NAME)
-  return snprintf(outbuf, COLWID, "%x", (unsigned)rSv(WCHAN_NAME, str, pp));
+setREL1(WCHAN_ADDR)
+  if (!(rSv(WCHAN_ADDR, ul_int, pp) & 0xffffff)) {
+    memcpy(outbuf, "-",2);
+    return 1;
+  }
+  return snprintf(outbuf, COLWID, "%x", (unsigned)rSv(WCHAN_ADDR, ul_int, pp));
 }
 
 /* Terrible trunctuation, like BSD crap uses: I999 J999 K999 */