NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: top(1) CPU states display is messed up



Ok, this seems to be the bug I introduced when I tried to fix top's 
display on machines with more than 9 CPUs. (See PR 43562)

Apply this patch (relatively to external/bsd/top) - pulling up dist/display.c
1.9 directly doesn't work due to constification conflicts - then
make USETOOLS=no in that directory and try the binary bin/top - 
and report, please.

Regards,
        -is

Index: dist/display.c
===================================================================
RCS file: /cvsroot/src/external/bsd/top/dist/display.c,v
retrieving revision 1.3.8.2
diff -u -r1.3.8.2 display.c
--- dist/display.c      21 Nov 2010 18:12:24 -0000      1.3.8.2
+++ dist/display.c      6 Dec 2010 13:23:06 -0000
@@ -849,10 +849,10 @@
            *ip++ = cpustate_total_length;
            if ((i = strlen(*pp++)) > 0)
            {
-               cpustate_total_length += i + 7;
-               /* strlen(" 100% ") is 6, strlen(" 99.9% ") is 7. Never 8. */
+               cpustate_total_length += i + 8;
            }
        }
+       cpustate_total_length -= 2;
     }
 
 #ifdef ENABLE_COLOR
@@ -1151,10 +1151,10 @@
 
     static char fmttag[100];
 
-    char *short_tag = !multi || ncpu <= 1 ? "CPU: " : "CPU%0*d";
+    char *short_tag = !multi || ncpu <= 1 ? "CPU: " : "CPU%0*d: ";
     char *long_tag = !multi || ncpu <= 1 ? "CPU states: " : "CPU%0*d states: ";
 
-    for (width=0, u=ncpu; u>0; u /= 10) {
+    for (width = 0, u = ncpu - 1; u > 0; u /= 10) {
        ++width;
     }
 




Home | Main Index | Thread Index | Old Index