]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
wafsamba/samba_autoconf: add -Werror=array-bounds -Werror=stringop-overflow gitlab/master
authorStefan Metzmacher <metze@samba.org>
Mon, 30 Mar 2026 15:17:47 +0000 (17:17 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 21 May 2026 18:27:37 +0000 (18:27 +0000)
Developer build should fail on such warnings...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu May 21 18:27:37 UTC 2026 on atb-devel-224

buildtools/wafsamba/samba_autoconf.py
lib/util/ms_fnmatch.c

index c21961e66db2b9783c89ccca7ead0e49cc867eb4..d7f7baa334d1aa4b97f7f3df19f8f42c04ab3043 100644 (file)
@@ -812,6 +812,10 @@ def SAMBA_CONFIG_H(conf, path=None):
                         testflags=True)
         conf.ADD_CFLAGS('-Werror=old-style-definition -Wold-style-definition',
                         testflags=True)
+        conf.ADD_CFLAGS('-Werror=array-bounds',
+                        testflags=True)
+        conf.ADD_CFLAGS('-Werror=stringop-overflow',
+                        testflags=True)
 
         conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
         conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True)
index 48454a8eccee4fa1bfaa64276b6598a37b2daf9e..0d70f03a3ab8a15fabbe3f5a6eaae59b5e07ad3d 100644 (file)
@@ -59,6 +59,15 @@ struct max_n {
   an optimisation only. The ldot pointer is NULL if the string does
   not contain a '.', otherwise it points at the last dot in 'n'.
 */
+
+/*
+ * GCC's constant propagation creates a specialised version of this function
+ * where max_n is typed as struct max_n[0] (past-the-end pointer from the
+ * caller). The code is correct, max_n is never dereferenced in constprop
+ * variants that have no remaining wildcards. GCC warns conservatively here.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
 static int ms_fnmatch_core(const char *p, const char *n,
                           struct max_n *max_n, const char *ldot,
                           bool is_case_sensitive)
@@ -175,6 +184,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
 
        return -1;
 }
+#pragma GCC diagnostic pop
 
 int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
                        bool is_case_sensitive)