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
This commit is contained in:
Ruslan Ermilov 2008-04-10 16:17:54 +00:00
parent f4d2c7f13e
commit f89db4357e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178071

View File

@ -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 */