[hackers] [slstatus] Remove non-portable functions from config.def.h || Aaron Marcher
commit 97ef7c2a1d67bb2c9c379e657fbc8e35acd6aafb Author: Aaron Marcher AuthorDate: Mon Apr 16 19:09:07 2018 +0200 Commit: Aaron Marcher CommitDate: Mon Apr 16 19:09:07 2018 +0200 Remove non-portable functions from config.def.h diff --git a/config.def.h b/config.def.h index 6370008..1e3be56 100644 --- a/config.def.h +++ b/config.def.h @@ -51,7 +51,5 @@ static const char unknown_str[] = "n/a"; */ static const struct arg args[] = { /* function format argument */ - { cpu_perc, "[CPU %3s%%] ", NULL}, - { ram_perc, "[RAM %2s%%] ", NULL}, - { datetime, "[ %s ]", "%F %T" }, + { datetime, "%s", "%F %T" }, };
Re: [hackers] [PATCH] Do not use valid in cpu_freq|io_wait
David, On the first call to the cpu_freq|cpu_iowait user may see an initial n/a result because NULL is returned but the value has been parsed correctly. Example: [CPU n/a%] [RAM 52%] [ 2018-04-16 15:55:19 ] [CPU 16%] [RAM 52%] [ 2018-04-16 15:55:20 ] [CPU 2%] [RAM 52%] [ 2018-04-16 15:55:21 ] thanks for your patch but I did not quite understand it. - if (!valid) { + if (!valid) valid = 1; - return NULL; - } First of all, that change removes the "return" statement which makes the code totally useless. Secondly, returning "unknown_str" for the first run of cpu_*() makes totally sense as those are average values between two executions. Regards, Aaron -- Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/ Gopher: gopher://drkhsh.at or gopher://drkhsh5rv6pnahas.onion GPG: 0x7A65E38D55BE96FE Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE
[hackers] [PATCH] Do not use valid in cpu_freq|io_wait
On the first call to the cpu_freq|cpu_iowait user may see an initial n/a result because NULL is returned but the value has been parsed correctly. Example: [CPU n/a%] [RAM 52%] [ 2018-04-16 15:55:19 ] [CPU 16%] [RAM 52%] [ 2018-04-16 15:55:20 ] [CPU 2%] [RAM 52%] [ 2018-04-16 15:55:21 ] --- components/cpu.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/cpu.c b/components/cpu.c index a001d14..646cdad 100644 --- a/components/cpu.c +++ b/components/cpu.c @@ -28,10 +28,8 @@ cpu_perc(void) &a[3], &a[4], &a[5], &a[6]) != 7) { return NULL; } - if (!valid) { + if (!valid) valid = 1; - return NULL; - } perc = 100 * ((b[0]+b[1]+b[2]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[5]+a[6])) / ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6])); @@ -52,10 +50,8 @@ cpu_iowait(void) &a[3], &a[4], &a[5], &a[6]) != 7) { return NULL; } - if (!valid) { + if (!valid) valid = 1; - return NULL; - } perc = 100 * ((b[4]) - (a[4])) / ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6])); -- 2.14.3
[hackers] [PATCH] Do not return NULL in cpu when setting valid
On the first call to the cpu_freq|cpu_iowait user may see an initial n/a result because NULL is returned but the value has been parsed correctly. Example: [CPU n/a%] [RAM 52%] [ 2018-04-16 15:55:19 ] [CPU 16%] [RAM 52%] [ 2018-04-16 15:55:20 ] [CPU 2%] [RAM 52%] [ 2018-04-16 15:55:21 ] --- components/cpu.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/cpu.c b/components/cpu.c index a001d14..646cdad 100644 --- a/components/cpu.c +++ b/components/cpu.c @@ -28,10 +28,8 @@ cpu_perc(void) &a[3], &a[4], &a[5], &a[6]) != 7) { return NULL; } - if (!valid) { + if (!valid) valid = 1; - return NULL; - } perc = 100 * ((b[0]+b[1]+b[2]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[5]+a[6])) / ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6])); @@ -52,10 +50,8 @@ cpu_iowait(void) &a[3], &a[4], &a[5], &a[6]) != 7) { return NULL; } - if (!valid) { + if (!valid) valid = 1; - return NULL; - } perc = 100 * ((b[4]) - (a[4])) / ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6])); -- 2.14.3