waf: Check for -Wno-error=array-bounds flags
authorAndreas Schneider <asn@samba.org>
Mon, 18 Jul 2022 08:39:05 +0000 (10:39 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 19 Jul 2022 12:17:35 +0000 (12:17 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15073

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jul 19 12:17:35 UTC 2022 on sn-devel-184

buildtools/wafsamba/samba_autoconf.py
lib/util/wscript_build

index 78927d851937a850aa7a4afc810a42a71ad0416b..9db53e40724b3bf8042120b7a6cebb519fb64911 100644 (file)
@@ -806,6 +806,9 @@ int main(void) {
                 conf.env['EXTRA_CFLAGS'] = []
             conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))
 
+        if CHECK_CFLAGS(conf, ["-Wno-error=array-bounds"]):
+            conf.define('HAVE_WNO_ERROR_ARRAY_BOUNDS', 1)
+
         if not Options.options.disable_warnings_as_errors:
             conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True)
             conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Wno-error=tautological-compare', testflags=True)
index e2194e68e3ed475890d4ca6f35d2a5f471f63c11..df235c13a70b84992752de62654eb4d9385be28a 100644 (file)
@@ -165,6 +165,16 @@ else:
                      local_include=False,
                      install=False)
 
+    # TODO: Rewrite ms_fnmatch_core() for a better API.
+    ms_fnmatch_cflags=''
+    if bld.CONFIG_SET('HAVE_WNO_ERROR_ARRAY_BOUNDS'):
+        ms_fnmatch_cflags='-Wno-error=array-bounds'
+    bld.SAMBA_SUBSYSTEM('SAMBA_UTIL_MS_FNMATCH',
+                        source='ms_fnmatch.c',
+                        deps='talloc',
+                        cflags=ms_fnmatch_cflags,
+                        local_include=False)
+
     bld.SAMBA_LIBRARY('samba-util',
                   source='''
                          base64.c
@@ -174,7 +184,6 @@ else:
                          getpass.c
                          idtree_random.c
                          memcache.c
-                         ms_fnmatch.c
                          params.c
                          rbtree.c
                          rfc1738.c
@@ -194,7 +203,15 @@ else:
                          util_str_common.c
                          util_strlist_v3.c
                          ''',
-                  deps='samba-util-core DYNCONFIG close-low-fd tiniparser genrand util_str_hex',
+                  deps='''
+                       samba-util-core
+                       DYNCONFIG
+                       close-low-fd
+                       tiniparser
+                       genrand
+                       util_str_hex
+                       SAMBA_UTIL_MS_FNMATCH
+                       ''',
                   public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid',
                   public_headers='''
                                  attr.h
@@ -212,7 +229,6 @@ else:
                                  tfork.h
                                  ''',
                   header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ],
-                  cflags='-Wno-error=array-bounds',
                   local_include=False,
                   vnum='0.0.1',
                   pc_files='samba-util.pc'