[LTP] [PATCH 2/5] lib: Add LTP_ATTRIBUTE_FALLTHROUGH for case statements

Cyril Hrubis chrubis@suse.cz
Thu Aug 30 17:46:08 CEST 2018


Hi!
> > +++ b/include/tst_common.h
> > @@ -24,6 +24,7 @@
> >  #define LTP_ATTRIBUTE_NORETURN		__attribute__((noreturn))
> >  #define LTP_ATTRIBUTE_UNUSED		__attribute__((unused))
> >  #define LTP_ATTRIBUTE_UNUSED_RESULT	__attribute__((warn_unused_result))
> > +#define LTP_ATTRIBUTE_FALLTHROUGH	__attribute__((fallthrough))
> This does not work on old GCC versions, it was added in GCC 7
> 
> * GCC < 7
> fcntl33.c: In function ???do_test???:
> fcntl33.c:160:3: warning: empty declaration
>    LTP_ATTRIBUTE_FALLTHROUGH;
> 
> IMHO the most portable way is to use comment /* Fall through */, but maybe we
> don't care much about.

And the comment actually stops the warning from being produced, nice.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list