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

Petr Vorel pvorel@suse.cz
Tue Aug 21 14:08:09 CEST 2018


Hi Richard,

> Can be used in place of break if you deliberately want to fallthrough to the
> next case statement.
...

> +++ 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.


Kind regards,
Petr


More information about the ltp mailing list