Skip to content

Commit

Permalink
gcc: handle the nonnull comparison issue more gracefully.
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Jones <[email protected]>
  • Loading branch information
vathpela committed Aug 11, 2016
1 parent f238fa7 commit 7d1e4c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc.specs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#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;
Expand Down
13 changes: 13 additions & 0 deletions src/include/efivar/efivar-dp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7d1e4c2

Please sign in to comment.