Possible bug in SMP top

Ståle Kristoffersen staalebk at ifi.uio.no
Tue Sep 4 10:26:04 UTC 2012


Hi, I have noticed a problem with top on a powerpc-based SMP system. The
'CPU' column is always 0.

Looking at the source it looks like there is a bug when checking the return
code of sscanf in procps.c. The patch following this e-mail seems to fix the
issue for me, and makes more sense seeing as we are passing 12 elements to
sscanf.

-- 
Ståle Kristoffersen
staalebk at ifi.uio.no

diff --git a/libbb/procps.c b/libbb/procps.c
index 40587db..348620d 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -425,7 +425,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
                        if (n < 11)
                                continue; /* bogus data, get next /proc/XXX */
 # if ENABLE_FEATURE_TOP_SMP_PROCESS
-                       if (n < 11+15)
+                       if (n < 12)
                                sp->last_seen_on_cpu = 0;
 # endif



More information about the busybox mailing list