diff mbox

[1/2] api: odp_hints: add ODP_NONNULL attribute

Message ID 1421099021-26007-3-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Jan. 12, 2015, 9:43 p.m. UTC
Both gcc and clang can use compiler hints to catch null passed as
an argument to a function. This macro allows ODP APIs to take advantage of
this feature.

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>

---
See also
http://clang-analyzer.llvm.org/annotations.html#generic

 platform/linux-generic/include/api/odp_hints.h | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_hints.h b/platform/linux-generic/include/api/odp_hints.h
index 7f04886..42b57f1 100644
--- a/platform/linux-generic/include/api/odp_hints.h
+++ b/platform/linux-generic/include/api/odp_hints.h
@@ -32,6 +32,12 @@  extern "C" {
 #define ODP_WEAK_SYMBOL __attribute__((__weak__))
 
 /**
+ * Where an API should not be passed a NULL pointer, provide static analysers
+ * a hint to help catch transgressions.
+ */
+#define ODP_NONNULL(...)    __attribute__((__nonnull__(__VA_ARGS__)))
+
+/**
  * Hot code section
  */
 #define ODP_HOT_CODE    __attribute__((__hot__))