From: Rusty Russell Date: Wed, 9 Jun 2021 05:42:28 +0000 (+0930) Subject: compiler: RETURNS_NONNULL macro X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=ec95c3c5f795ce9019809fec5578fabb22ec8c56;p=ccan compiler: RETURNS_NONNULL macro Signed-off-by: Rusty Russell --- 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 /**