Skip to content

Commit 2183fb1

Browse files
committed
nedmalloc: work around overzealous GCC 6 warning
With GCC 6, the strdup() function is declared with the "nonnull" attribute, stating that it is not allowed to pass a NULL value as parameter. In nedmalloc()'s reimplementation of strdup(), Postel's Law is heeded and NULL parameters are handled gracefully. GCC 6 complains about that now because it thinks that NULL cannot be passed to strdup() anyway. Let's just shut up GCC >= 6 in that case and go on with our lives. See https://gcc.gnu.org/gcc-6/porting_to.html for details. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d4301ea commit 2183fb1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compat/nedmalloc/nedmalloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,9 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **
956956
char *strdup(const char *s1)
957957
{
958958
char *s2 = 0;
959+
#if __GNUC__ >= 6
960+
#pragma GCC diagnostic ignored "-Wnonnull-compare"
961+
#endif
959962
if (s1) {
960963
size_t len = strlen(s1) + 1;
961964
s2 = malloc(len);

0 commit comments

Comments
 (0)