[PATCH 1/2] Linux: implement getloadavg(3) using sysinfo(2)

Cristian Rodríguez crrodriguez@opensuse.org
Thu Aug 19 21:38:24 GMT 2021


On Thu, Aug 19, 2021 at 3:17 PM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 06/08/2021 16:17, Cristian Rodríguez wrote:
> > Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
>
> Look good, some minor comments below.

First, thanks for looking..

> > +  struct sysinfo info = {};
>
> I think there is no need to clear the struct prior the syscall,
> I would expect the kernel to fill all the appropriated values
> (as it seems to be doing on kernel/sys.c).


Yes, I read the kernel source, I  just decided not to count on the
kernel doing it.


> > +  nelem = CLAMP (nelem, 0, (int)array_length (info.loads));
>
> I think there is no need to cast to int here

IIRC the compiler complained I was comparing signed and unsigned
values.. array_length expands to a size_t value.


More information about the Libc-alpha mailing list