From: Bartosz Golaszewski Date: Wed, 1 Mar 2017 11:46:36 +0000 (+0100) Subject: tests: use the 'malloc' attribute X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=76c4606a3d14a5d0be334e74666f9a285b2db23a;p=qemu-gpiodev%2Flibgpiod.git tests: use the 'malloc' attribute Use the gcc 'malloc' attribute for all malloc-like routines in the unit testing framework. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/unit/gpiod-unit.c b/tests/unit/gpiod-unit.c index 0c462d1..2b8f81b 100644 --- a/tests/unit/gpiod-unit.c +++ b/tests/unit/gpiod-unit.c @@ -19,7 +19,8 @@ #include #include -#define NORETURN __attribute__((noreturn)) +#define NORETURN __attribute__((noreturn)) +#define MALLOC __attribute__((malloc)) static const char mockup_devpath[] = "/devices/platform/gpio-mockup/gpiochip"; @@ -146,7 +147,7 @@ static GU_PRINTF(1, 2) NORETURN void die_perr(const char *fmt, ...) exit(EXIT_FAILURE); } -static void * xzalloc(size_t size) +static MALLOC void * xzalloc(size_t size) { void *ptr; @@ -159,7 +160,7 @@ static void * xzalloc(size_t size) return ptr; } -static char * xstrdup(const char *str) +static MALLOC char * xstrdup(const char *str) { char *ret; @@ -170,7 +171,7 @@ static char * xstrdup(const char *str) return ret; } -static GU_PRINTF(2, 3) char * xappend(char *str, const char *fmt, ...) +static MALLOC GU_PRINTF(2, 3) char * xappend(char *str, const char *fmt, ...) { char *new, *ret; va_list va;