Perhaps it might be cleaner to save the sum away in separate variables
instead of accessing the states several times. Or better extract into
a separate function/macro. Also mind doing it for FreeBSD and Linux?
Since they use the same logic

Regards,
Michael

Am Mi., 13. Feb. 2019 um 23:20 Uhr schrieb Ingo Feinerer <[email protected]>:
>
> ---
>  components/cpu.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/components/cpu.c b/components/cpu.c
> index d9bd018..47a10c5 100644
> --- a/components/cpu.c
> +++ b/components/cpu.c
> @@ -92,6 +92,11 @@
>                         return NULL;
>                 }
>
> +               if (a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR] + 
> a[CP_IDLE] ==
> +                   b[CP_USER] + b[CP_NICE] + b[CP_SYS] + b[CP_INTR] + 
> b[CP_IDLE]) {
> +                       return NULL;
> +               }
> +
>                 return bprintf("%d", 100 *
>                                ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] +
>                                  a[CP_INTR]) -
> --
> 2.20.1
>
>

Reply via email to