From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 14:21:47 +0000 (+0100) Subject: tools-common: add gcc attributes X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4d5c016bd1b6dcc965278f80c960e942eb627ce4;p=qemu-gpiodev%2Flibgpiod.git tools-common: add gcc attributes Add macros for two gcc attributes and use them in die() and die_perror(). Signed-off-by: Bartosz Golaszewski --- diff --git a/tools-common.c b/tools-common.c index 43b9242..cd2dd0a 100644 --- a/tools-common.c +++ b/tools-common.c @@ -15,6 +15,9 @@ #include #include +#define NORETURN __attribute__((noreturn)) +#define PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) + static char *progname = "unknown"; void set_progname(char *name) @@ -27,7 +30,7 @@ const char * get_progname(void) return progname; } -void die(const char *fmt, ...) +void NORETURN PRINTF(1, 2) die(const char *fmt, ...) { va_list va; @@ -40,7 +43,7 @@ void die(const char *fmt, ...) exit(EXIT_FAILURE); } -void die_perror(const char *fmt, ...) +void NORETURN PRINTF(1, 2) die_perror(const char *fmt, ...) { va_list va;