compiler: RETURNS_NONNULL macro master origin/master
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 9 Jun 2021 05:42:28 +0000 (15:12 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 9 Jun 2021 05:42:28 +0000 (15:12 +0930)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/compiler/compiler.h

index 1bbb3b8b61c6cb4a0fd44ab39e5bf7505eaa91bd..562b29ec71cc13969ab0d111477608cdbc9d9c36 100644 (file)
 #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
 /**