[PATCH] [libgpiod 0.3.x] tools: move function attributes to the header file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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>
---
[Backported to libgpiod 0.3.x]

 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 ee4a838..b6ae18e 100644
--- a/src/tools/tools-common.c
+++ b/src/tools/tools-common.c
@@ -18,8 +18,6 @@
 #include <stdarg.h>
 #include <libgen.h>
 
-#define NORETURN		__attribute__((noreturn))
-
 static char *progname = "unknown";
 
 void set_progname(char *name)
@@ -32,7 +30,7 @@ const char * get_progname(void)
 	return progname;
 }
 
-void NORETURN PRINTF(1, 2) die(const char *fmt, ...)
+void die(const char *fmt, ...)
 {
 	va_list va;
 
@@ -45,7 +43,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 47dd003..c116df2 100644
--- a/src/tools/tools-common.h
+++ b/src/tools/tools-common.h
@@ -20,13 +20,14 @@
  */
 
 #define UNUSED			__attribute__((unused))
+#define NORETURN		__attribute__((noreturn))
 #define PRINTF(fmt, arg)	__attribute__((format(printf, fmt, arg)))
 #define ARRAY_SIZE(x)		(sizeof(x) / sizeof(*(x)))
 
 void set_progname(char *name);
 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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux