diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-08-06 16:56:00 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-08-06 16:59:50 +0200 |
commit | 85b380f6b21816b3392a987d35cfc79c25ec0ffd (patch) | |
tree | 21e217596ee78343bc9c354353c99d420147fc72 | |
parent | b81f80565854d59c0209a6dbaa2022caa6f0d468 (diff) | |
download | busybox-w32-85b380f6b21816b3392a987d35cfc79c25ec0ffd.tar.gz busybox-w32-85b380f6b21816b3392a987d35cfc79c25ec0ffd.tar.bz2 busybox-w32-85b380f6b21816b3392a987d35cfc79c25ec0ffd.zip |
nmeter: do not clamp down %Nc to minimum of 10 (think nmeter "%`nproc`c")
Also, go for unsigned divisions.
function old new delta
init_cpu 61 73 +12
collect_cpu 444 422 -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-22) Total: -10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/nmeter.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c index a01d19a6a..f0eb36740 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -351,7 +351,7 @@ static s_stat* init_cr(const char *param UNUSED_PARAM) | |||
351 | enum { CPU_FIELDCNT = 7 }; | 351 | enum { CPU_FIELDCNT = 7 }; |
352 | S_STAT(cpu_stat) | 352 | S_STAT(cpu_stat) |
353 | ullong old[CPU_FIELDCNT]; | 353 | ullong old[CPU_FIELDCNT]; |
354 | int bar_sz; | 354 | unsigned bar_sz; |
355 | char bar[1]; | 355 | char bar[1]; |
356 | S_STAT_END(cpu_stat) | 356 | S_STAT_END(cpu_stat) |
357 | 357 | ||
@@ -360,8 +360,8 @@ static void FAST_FUNC collect_cpu(cpu_stat *s) | |||
360 | ullong data[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 }; | 360 | ullong data[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 }; |
361 | unsigned frac[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 }; | 361 | unsigned frac[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 }; |
362 | ullong all = 0; | 362 | ullong all = 0; |
363 | int norm_all = 0; | 363 | unsigned norm_all = 0; |
364 | int bar_sz = s->bar_sz; | 364 | unsigned bar_sz = s->bar_sz; |
365 | char *bar = s->bar; | 365 | char *bar = s->bar; |
366 | int i; | 366 | int i; |
367 | 367 | ||
@@ -420,8 +420,8 @@ static s_stat* init_cpu(const char *param) | |||
420 | { | 420 | { |
421 | int sz; | 421 | int sz; |
422 | cpu_stat *s; | 422 | cpu_stat *s; |
423 | sz = strtoul(param, NULL, 0); /* param can be "" */ | 423 | sz = param[0] ? strtoul(param, NULL, 0) : 10; |
424 | if (sz < 10) sz = 10; | 424 | if (sz <= 0) sz = 1; |
425 | if (sz > 1000) sz = 1000; | 425 | if (sz > 1000) sz = 1000; |
426 | s = xzalloc(sizeof(*s) + sz); | 426 | s = xzalloc(sizeof(*s) + sz); |
427 | /*s->bar[sz] = '\0'; - xzalloc did it */ | 427 | /*s->bar[sz] = '\0'; - xzalloc did it */ |