The attributes should be in the definition in the header file. Otherwise, the noreturn attribute seems to have no effect and GCC emits several Wimplicit-fallthrough warnings when compiling libgpiod. This patch fixes those warnings. Signed-off-by: Clemens Gruber <clemens.gruber@xxxxxxxxxxxx> --- src/tools/tools-common.c | 6 ++---- src/tools/tools-common.h | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/tools/tools-common.c b/src/tools/tools-common.c index 4c138a8..1bc17e2 100644 --- a/src/tools/tools-common.c +++ b/src/tools/tools-common.c @@ -21,14 +21,12 @@ #include <libgen.h> #include <errno.h> -#define NORETURN __attribute__((noreturn)) - const char * get_progname(void) { return program_invocation_name; } -void NORETURN PRINTF(1, 2) die(const char *fmt, ...) +void die(const char *fmt, ...) { va_list va; @@ -41,7 +39,7 @@ void NORETURN PRINTF(1, 2) die(const char *fmt, ...) exit(EXIT_FAILURE); } -void NORETURN PRINTF(1, 2) die_perror(const char *fmt, ...) +void die_perror(const char *fmt, ...) { va_list va; diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h index 0f8e92b..dad18a4 100644 --- a/src/tools/tools-common.h +++ b/src/tools/tools-common.h @@ -19,14 +19,15 @@ * common code. */ +#define NORETURN __attribute__((noreturn)) #define PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #define GETOPT_NULL_LONGOPT NULL, 0, NULL, 0 const char * get_progname(void); -void die(const char *fmt, ...); -void die_perror(const char *fmt, ...); +void die(const char *fmt, ...) NORETURN PRINTF(1, 2); +void die_perror(const char *fmt, ...) NORETURN PRINTF(1, 2); void print_version(void); #endif /* __GPIOD_TOOLS_COMMON_H__ */ -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html