summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-06 18:46:30 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-06 20:51:56 +1000
commit33c79c8731ea0c1ab78583a7c50953c56aea539f (patch)
tree1bd73471184be5a1405c0248a76c44a4a0e5291a
parent0514a84f7e7d44eae3c7fcc85fc804af6fbfda6b (diff)
downloadsamba-33c79c8731ea0c1ab78583a7c50953c56aea539f.tar.gz
samba-33c79c8731ea0c1ab78583a7c50953c56aea539f.tar.bz2
samba-33c79c8731ea0c1ab78583a7c50953c56aea539f.zip
build: Make -Werror=format check only run where NULL is still accepted
This is needed because ldb_search() allows a NULL parameter for the format string and this needs to be permitted by the format string checker before we want to make this error fatal. Andrew Bartlett
-rw-r--r--buildtools/wafsamba/samba_autoconf.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index cfab476ad2..03c2b242fb 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -437,10 +437,10 @@ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
@conf
-def CHECK_CFLAGS(conf, cflags):
+def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'):
'''check if the given cflags are accepted by the compiler
'''
- return conf.check(fragment='int main(void) { return 0; }\n',
+ return conf.check(fragment=fragment,
execute=0,
type='nolink',
ccflags=cflags,
@@ -622,11 +622,26 @@ def SAMBA_CONFIG_H(conf, path=None):
if Options.options.developer:
# we add these here to ensure that -Wstrict-prototypes is not set during configure
- conf.ADD_CFLAGS('-Wall -g -Wshadow -Werror=strict-prototypes -Wstrict-prototypes -Werror=pointer-arith -Wpointer-arith -Wcast-align -Werror=write-strings -Wwrite-strings -Werror-implicit-function-declaration -Werror=format -Wformat=2 -Wno-format-y2k -Wmissing-prototypes -fno-common -Werror=address',
+ conf.ADD_CFLAGS('-Wall -g -Wshadow -Werror=strict-prototypes -Wstrict-prototypes -Werror=pointer-arith -Wpointer-arith -Wcast-align -Werror=write-strings -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wmissing-prototypes -fno-common -Werror=address',
testflags=True)
conf.ADD_CFLAGS('-Wcast-qual', testflags=True)
conf.env.DEVELOPER_MODE = True
+ # This check is because for ldb_search(), a NULL format string
+ # is not an error, but some compilers complain about that.
+ if CHECK_CFLAGS(conf, "-Werror=format", '''
+int testformat(char *format, ...) __attribute__ ((format (__printf__, 1, 2)));
+
+int main(void) {
+ testformat(0);
+ return 0;
+}
+
+'''):
+ if not 'EXTRA_CFLAGS' in conf.env:
+ conf.env['EXTRA_CFLAGS'] = []
+ conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))
+
if Options.options.picky_developer:
conf.ADD_CFLAGS('-Werror', testflags=True)