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

Petr Vorel pvorel@suse.cz
Fri Mar 22 10:34:52 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.

Thanks for info, Jan. I suppose the problem is also on older
gcc (nothing gcc 11 specific). We compile also on gcc 4.8 and 7.3.

Is it also problem for older clang?

If I understand correctly it should be safe to use {0}, and {} probably waits
for the future.

Kind regards,
Petr

> > Kind regards,
> > Petr




More information about the ltp mailing list