[PATCH] tst: Provide test for timerfd related functions

Lukasz Majewski lukma@denx.de
Wed Jan 13 22:25:02 GMT 2021


Hi Florian,

> * Lukasz Majewski:
> 
> > +  fd = timerfd_create(CLOCK_REALTIME, 0);
> > +  if (fd < 0)
> > +    {
> > +	    printf ("*** timerfd_create failed: %d\n", fd);
> > +      return fd;
> > +    }  
> 
> Please use FAIL_EXIT1 with %m, and add spaces in function calls, e.g.,
> “timerfd_create (CLOCK_REALTIME, 0)”.
> 
> This others to the other function calls in the code.

Ok. I will adjust the code properly. Thanks for pointing this out.

> 
> > +  /* Check difference between timerfd_gettime() calls.  */
> > +  long long int diff = val1.it_value.tv_sec - val2.it_value.tv_sec;
> > +  diff *= 1000000000;
> > +  diff += val1.it_value.tv_nsec - val2.it_value.tv_nsec;
> > +  diff -= 1000000000;
> > +  diff = abs(diff);
> > +  if (diff > 100000000)
> > +    {
> > +      printf ("*** The diff between timerfd calls (%lld) is
> > wrong!\n",
> > +              diff);
> > +      goto err;
> > +    }  
> 
> Why diff = abs (diff)?  Can the offset really be in both directions?

I've refactored the code and now it seems like the abs (diff) can be
safely removed.

> 
> > +  ret = close(fd);  
> 
> You could use xclose here.

Ok.

> 
> Thanks,
> Florian




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20210113/80f49da3/attachment.sig>


More information about the Libc-alpha mailing list