[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

glob: fix over-optimization due to attribute __nonnull__

From: Bruno Haible
Subject: glob: fix over-optimization due to attribute __nonnull__
Date: Sun, 19 Aug 2018 12:04:03 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-130-generic; KDE/5.18.0; x86_64; ; )

On Mac OS X, while compiling a testdir for module 'glob', I see this warning:

glob.c:282:7: warning: comparison of nonnull parameter 'pattern' equal to a 
null pointer is 'false' on first encounter [-Wtautological-pointer-compare]
  if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
      ^~~~~~~    ~~~~
./glob.h:585:31: note: declared 'nonnull' here
                              _GL_ARG_NONNULL ((1)));

This patch fixes it.

2018-08-19  Bruno Haible  <address@hidden>

        glob: Fix over-optimization due to attribute __nonnull__.
        * lib/glob.c (_GL_ARG_NONNULL): Define to empty.

diff --git a/lib/glob.c b/lib/glob.c
index 17ec19a..b40474d 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -16,7 +16,13 @@
    <https://www.gnu.org/licenses/>.  */
 #ifndef _LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the pattern == NULL test below.  */
+# define _GL_ARG_NONNULL(params)
 # include <config.h>
 #include <glob.h>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]