OSDN Git Service

gcc: handle the nonnull comparison issue more gracefully.
authorPeter Jones <pjones@redhat.com>
Thu, 11 Aug 2016 18:09:44 +0000 (14:09 -0400)
committerPeter Jones <pjones@redhat.com>
Thu, 11 Aug 2016 19:34:04 +0000 (15:34 -0400)
Signed-off-by: Peter Jones <pjones@redhat.com>
gcc.specs
src/error.c
src/include/efivar/efivar-dp.h

index a9c3ce5..0d4bbda 100644 (file)
--- a/gcc.specs
+++ b/gcc.specs
@@ -2,7 +2,7 @@
 + -D_GNU_SOURCE
 
 *efivar_cpp_options:
- -Werror -Wall -std=gnu11 -Wextra -Wno-nonnull-compare
+ -Werror -Wall -std=gnu11 -Wextra
 
 *cpp_options:
 + %(efivar_cpp_options)
index e8e3004..79f7734 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+/*
+ * GCC complains that we check for null if we have a nonnull attribute, even
+ * though older or other compilers might just ignore that attribute if they
+ * don't support it.  Ugh.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 6
+#pragma GCC diagnostic ignored "-Wnonnull-compare"
+#endif
 
 typedef struct {
        int error;
index a21cd2a..a923ede 100644 (file)
@@ -696,6 +696,15 @@ extern int efidp_append_path(const_efidp dp0, const_efidp dp1, efidp *out);
 extern int efidp_append_node(const_efidp dp, const_efidp dn, efidp *out);
 extern int efidp_append_instance(const_efidp dp, const_efidp dpi, efidp *out);
 
+/*
+ * GCC complains that we check for null if we have a nonnull attribute, even
+ * though older or other compilers might just ignore that attribute if they
+ * don't support it.  Ugh.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 6
+#pragma GCC diagnostic ignored "-Wnonnull-compare"
+#endif
+
 static inline int16_t
 __attribute__((__artificial__))
 __attribute__((__nonnull__(1)))
@@ -999,6 +1008,10 @@ efidp_is_valid(const_efidp dp, ssize_t limit)
        return 1;
 }
 
+#if defined(__GNUC__) && __GNUC__ >= 6
+#pragma GCC diagnostic pop
+#endif
+
 /* and now, printing and parsing */
 extern ssize_t efidp_parse_device_node(char *path, efidp out, size_t size);
 extern ssize_t efidp_parse_device_path(char *path, efidp out, size_t size);