From ec95c3c5f795ce9019809fec5578fabb22ec8c56 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 9 Jun 2021 15:12:28 +0930 Subject: [PATCH] compiler: RETURNS_NONNULL macro Signed-off-by: Rusty Russell --- ccan/compiler/compiler.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ccan/compiler/compiler.h b/ccan/compiler/compiler.h index 1bbb3b8b..562b29ec 100644 --- a/ccan/compiler/compiler.h +++ b/ccan/compiler/compiler.h @@ -271,6 +271,19 @@ #define NON_NULL_ARGS(...) #endif +#if HAVE_ATTRIBUTE_RETURNS_NONNULL +/** + * RETURNS_NONNULL - specify that this function cannot return NULL. + * + * Mainly an optimization opportunity, but can also suppress warnings. + * + * Example: + * RETURNS_NONNULL char *my_copy(char *buf); + */ +#define RETURNS_NONNULL __attribute__((__returns_nonnull__)) +#else +#define RETURNS_NONNULL +#endif #if HAVE_ATTRIBUTE_SENTINEL /** -- 2.39.2