From a5ee3d7c4fe58dc838cdf3cfb5fabde1ddf2c910 Mon Sep 17 00:00:00 2001 From: Clemens Gruber Date: Tue, 20 Feb 2018 17:57:32 +0100 Subject: [PATCH] tools: move function attributes to the header file The attributes must be located next to function declarations 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 Signed-off-by: Bartosz Golaszewski --- 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 #include -#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.30.2