[LTP] [PATCH v2] syscalls/timer_getoverrun01: use kernel_timer_t type

Jan Stancek jstancek@redhat.com
Fri Mar 22 09:51:46 CET 2024


On Fri, Mar 22, 2024 at 6:11 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan,
>
> ...
> > +++ b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
> > @@ -19,10 +19,11 @@
> >  #include <time.h>
> >  #include "tst_safe_clocks.h"
> >  #include "lapi/syscalls.h"
> > +#include "lapi/common_timers.h"
>
> >  static void run(void)
> >  {
> > -     timer_t timer;
> > +     kernel_timer_t timer;
>
> Good catch.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> BTW in v1 you used memset(&timer, 0, sizeof(timer_t));
> Could have we used with current compilers just timer_t timer = {} instead of
> memset()? Or what is the reason we keep using memset() instead of {}?

I treated it as opaque type. If it was a scalar, plain {} doesn't work with all
compilers. For example this fails to compile for me with gcc 11:
int main() { int i = {}; return i; }

$ gcc  -Wpedantic a.c
a.c: In function ‘main’:
a.c:1:22: warning: ISO C forbids empty initializer braces [-Wpedantic]
    1 | int main() { int i = {}; return i; }
      |                      ^
a.c:1:22: error: empty scalar initializer
a.c:1:22: note: (near initialization for ‘i’)

"{0}" should work - I guess I was just being too careful.

>
> Kind regards,
> Petr
>



More information about the ltp mailing list