Re: [hackers] [PATCH] Do not use valid in cpu_freq|io_wait

From: Aaron Marcher <me_AT_drkhsh.at>
Date: Mon, 16 Apr 2018 17:33:23 +0200

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
Received on Mon Apr 16 2018 - 17:33:23 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 16 2018 - 17:36:25 CEST