diff options
author | ru <ru@FreeBSD.org> | 2008-04-10 16:17:54 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2008-04-10 16:17:54 +0000 |
commit | ec3cc8a11581d068677d63f6eee80539d5fee78d (patch) | |
tree | 8cdf4eefadde298cef55697c2f881b88156f3381 /usr.bin | |
parent | 062b34d1bec21657554ef926fae09b48fdedb42d (diff) | |
download | FreeBSD-src-ec3cc8a11581d068677d63f6eee80539d5fee78d.zip FreeBSD-src-ec3cc8a11581d068677d63f6eee80539d5fee78d.tar.gz |
Fix "top -P" (`&' mistyped as `&&' and a botched logic).
The bug was unnoticed on non-i386 because mp_maxid is
initialized differently, kern.cp_times doesn't print
zeroes for non-existing CPUs, so no "writing outside of
array bounds" happens.
MFC after: 3 days
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/top/machine.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index f042079..21bf033 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -413,14 +413,15 @@ get_system_info(struct system_info *si) si->load_avg[i] = (double)sysload.ldavg[i] / sysload.fscale; if (pcpu_stats) { - for (i = j = 0; i <= maxid; i++, j++) { - if (cpumask && (1ul << i) == 0) + for (i = j = 0; i <= maxid; i++) { + if ((cpumask & (1ul << i)) == 0) continue; /* convert cp_time counts to percentages */ percentages(CPUSTATES, &pcpu_cpu_states[j * CPUSTATES], &pcpu_cp_time[j * CPUSTATES], &pcpu_cp_old[j * CPUSTATES], &pcpu_cp_diff[j * CPUSTATES]); + j++; } } else { /* convert cp_time counts to percentages */ |