From f01f8d405ba6b67e7648792e2e6a70ce71fb8ea8 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sun, 8 Oct 2023 13:09:34 +0200 Subject: [PATCH] Annotate do_nofail() with malloc(free) and returns_nonnull Or else the compiler will be unable to understand that the NOFAIL() macro never returns a NULL pointer. --- utils.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.h b/utils.h index c733bdf..7cb0947 100644 --- a/utils.h +++ b/utils.h @@ -17,8 +17,12 @@ /* Portability macros */ #ifdef __GNUC__ # define NORETURN __attribute__((noreturn)) +# define MALLOC_FREE __attribute__((malloc(free))) +# define NONNULL __attribute__((returns_nonnull)) #else # define NORETURN +# define MALLOC_FREE +# define NONNULL #endif #ifndef AI_IDN @@ -55,7 +59,8 @@ #endif /* Prototypes */ -void *do_nofail(void *ptr, const char *file, const int line); +void *MALLOC_FREE NONNULL do_nofail(void *ptr, const char *file, const int line) +; char **merge_args(char *args, char *argv[], int *argc); void NORETURN err_quit(const char *fmt, ...);