[PATCH] Revert "wafsamba: Enable warnings for missing field initializer"

Christof Schmitt cs at samba.org
Mon Apr 29 22:32:11 UTC 2019


On Mon, Apr 29, 2019 at 01:08:09PM -0700, Christof Schmitt via samba-technical wrote:
> On Mon, Apr 29, 2019 at 09:51:53PM +0200, Ralph Böhme wrote:
> > Hey Christof
> > 
> > > Am 29.04.2019 um 21:36 schrieb Christof Schmitt <cs at samba.org>:
> > > 
> > > Revert the patch adding the warnings since that causes problems when
> > > compiling master on RHEL7. Many C99 initializers of nested structs
> > > are flagged as problematic, so it seems easier to remove the
> > > additional compiler checks.
> > 
> > sorry, didn't thought about older compilers...
> > 
> > Can we have a compiler check that ensures {0} works included with
> > nested structs and then only enable the -Wmissing-field-initializers
> > if it does?
> 
> That should be doable. Let met try adding the check.

See attached patch. That works for me on RHEL7 (skipping the compiler
option) and Fedora 29 (using the compiler option).

Christof
-------------- next part --------------
From 3c604521632a63a0baf210b6573812466435f024 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 29 Apr 2019 13:07:08 -0700
Subject: [PATCH] wafsamba: Add compiler check for missing field initializer
 check

cf79ee15 wafsamba: Enable warnings for missing field initializer

enabled a compiler check for warnings about missing initializers for all
developer builds. This fails with older compilers, e.g. gcc on RHEL7.
Add a waf check around adding the compiler option to avoid the failure
with older compilers.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index f2b049e40a7..06ec7da333a 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -731,7 +731,13 @@ def SAMBA_CONFIG_H(conf, path=None):
         conf.ADD_CFLAGS('-Wall', testflags=True)
         conf.ADD_CFLAGS('-Wshadow', testflags=True)
         conf.ADD_CFLAGS('-Wmissing-prototypes', testflags=True)
-        conf.ADD_CFLAGS('-Wmissing-field-initializers', testflags=True)
+        if CHECK_CODE(conf,
+                      'struct a { int b; }; struct c { struct a d; } e = { };',
+                      'CHECK_C99_INIT',
+                      link=False,
+                      cflags='-Wmissing-field-initializers -Werror=missing-field-initializers',
+                      msg="Checking C99 init of nested structs."):
+            conf.ADD_CFLAGS('-Wmissing-field-initializers', testflags=True)
         conf.ADD_CFLAGS('-Wcast-align -Wcast-qual', testflags=True)
         conf.ADD_CFLAGS('-fno-common', testflags=True)
 
-- 
2.17.0



More information about the samba-technical mailing list