Add RPM_GNUC_NONNULL macro for portable use of gcc nonnull attribute
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Sep 2009 08:16:16 +0000 (11:16 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Sep 2009 08:16:16 +0000 (11:16 +0300)
- gcc itself can only warn on literal NULL's passed where nonnull is
  expected but static analyzers can make better use of the info

rpmio/rpmutil.h

index 19a7a9c..746dae5 100644 (file)
 #endif /* __GNUC__ */
 
 #if     __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
-#  define RPM_GNUC_MAY_ALIAS __attribute__((may_alias))
+#define RPM_GNUC_MAY_ALIAS __attribute__((may_alias))
+#define RPM_GNUC_NONNULL( ... )        \
+  __attribute__((__nonnull__ (__VA_ARGS__)))
 #else
-#  define RPM_GNUC_MAY_ALIAS
+#define RPM_GNUC_MAY_ALIAS
+#define RPM_GNUC_NONNULL( ... )
 #endif
 
 #if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)