]> git.ozlabs.org Git - ccan/blobdiff - ccan/compiler/compiler.h
compiler: RETURNS_NONNULL macro
[ccan] / 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
 /**