top tests to see if wchan is set before printing wmesg, but this
doesn't work anymore, since regular users can't see wchan. this fixes
it. note that some of the removed code was already busted since wmesg
is an array, not a pointer.

Index: machine.c
===================================================================
RCS file: /cvs/src/usr.bin/top/machine.c,v
retrieving revision 1.75
diff -u -p -r1.75 machine.c
--- machine.c   18 Dec 2012 21:28:45 -0000      1.75
+++ machine.c   23 Mar 2013 10:33:30 -0000
@@ -464,7 +464,7 @@ format_comm(struct kinfo_proc *kp)
 char *
 format_next_process(caddr_t handle, char *(*get_userid)(uid_t), pid_t *pid)
 {
-       char *p_wait, waddr[sizeof(void *) * 2 + 3];    /* Hexify void pointer 
*/
+       char *p_wait;
        struct kinfo_proc *pp;
        struct handle *hp;
        int cputime;
@@ -480,15 +480,9 @@ format_next_process(caddr_t handle, char
        /* calculate the base for cpu percentages */
        pct = pctdouble(pp->p_pctcpu);
 
-       if (pp->p_wchan) {
-               if (pp->p_wmesg)
-                       p_wait = pp->p_wmesg;
-               else {
-                       snprintf(waddr, sizeof(waddr), "%llx",
-                           (unsigned long long)pp->p_wchan);
-                       p_wait = waddr;
-               }
-       } else
+       if (pp->p_wmesg[0])
+               p_wait = pp->p_wmesg;
+       else
                p_wait = "-";
 
        /* format this entry */

Reply via email to