aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-11-04 23:22:40 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-11-04 23:22:40 +0100
commitdcb163aa8e7808b59aef3d3319c707e7d9ac4ce4 (patch)
treee1beb028bc752ed67f3c4ca752246a646b6895c3
parent3bbfb58bec18990a2ee93f31ea1ee2fd19c4d9b2 (diff)
downloadbusybox-w32-dcb163aa8e7808b59aef3d3319c707e7d9ac4ce4.tar.gz
busybox-w32-dcb163aa8e7808b59aef3d3319c707e7d9ac4ce4.tar.bz2
busybox-w32-dcb163aa8e7808b59aef3d3319c707e7d9ac4ce4.zip
powertop: replace erroneous \n with \0; make numberic conversion more robust
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--procps/powertop.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/procps/powertop.c b/procps/powertop.c
index 4c3c3565e..87efbe892 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -323,18 +323,16 @@ static void process_irq_counts(void)
323 */ 323 */
324 *p = '\0'; 324 *p = '\0';
325 /* Deal with non-maskable interrupts -- make up fake numbers */ 325 /* Deal with non-maskable interrupts -- make up fake numbers */
326 nr = index_in_strings("NMI\0RES\nCAL\0TLB\0TRM\0THR\0SPU\0", buf); 326 nr = index_in_strings("NMI\0RES\0CAL\0TLB\0TRM\0THR\0SPU\0", buf);
327 if (nr != -1) { 327 if (nr >= 0) {
328 nr += 20000; 328 nr += 20000;
329 } else { 329 } else {
330 /* bb_strtou doesn't eat leading spaces, using strtoul */ 330 /* bb_strtou doesn't eat leading spaces, using strtoul */
331 errno = 0;
331 nr = strtoul(buf, NULL, 10); 332 nr = strtoul(buf, NULL, 10);
333 if (errno)
334 continue;
332 } 335 }
333 *p = ':';
334
335 if (nr == -1)
336 continue;
337
338 p++; 336 p++;
339 /* 0: 143646045 153901007 IO-APIC-edge timer 337 /* 0: 143646045 153901007 IO-APIC-edge timer
340 * ^ 338 * ^