[dpdk-dev,v1,1/1] test: fix build with GCC 4.8.5
Checks
Commit Message
Build errors occur on CentOS 7 with GCC 4.8.5 20150623 in the
event_timer_adapter_test autotest; the
-Werror=missing-field-initializers option causes the compiler to emit
messages like "error: missing initializer for field ‘priority’ of
‘struct <anonymous>’" in several places.
Add -Wno-missing-field-initializers to the test's CFLAGS to allow the
current syntax if we are using GCC 5.0 or lower.
Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
---
test/test/Makefile | 1 +
1 file changed, 1 insertion(+)
Comments
-----Original Message-----
> Date: Fri, 4 May 2018 16:38:03 -0500
> From: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> To: jerin.jacob@caviumnetworks.com
> CC: dev@dpdk.org
> Subject: [PATCH v1 1/1] test: fix build with GCC 4.8.5
> X-Mailer: git-send-email 1.7.10
>
> Build errors occur on CentOS 7 with GCC 4.8.5 20150623 in the
> event_timer_adapter_test autotest; the
> -Werror=missing-field-initializers option causes the compiler to emit
> messages like "error: missing initializer for field ‘priority’ of
> ‘struct <anonymous>’" in several places.
>
> Add -Wno-missing-field-initializers to the test's CFLAGS to allow the
> current syntax if we are using GCC 5.0 or lower.
>
Missing the 'Fixes' tag:
With above change:
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> ---
> test/test/Makefile | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/test/test/Makefile b/test/test/Makefile
> index 2630ab4..2011857 100644
> --- a/test/test/Makefile
> +++ b/test/test/Makefile
> @@ -211,6 +211,7 @@ CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
> # designated initializers.
> ifeq ($(shell test $(GCC_VERSION) -le 50 && echo 1), 1)
> CFLAGS_test_eventdev_sw.o += -Wno-missing-field-initializers
> +CFLAGS_test_event_timer_adapter.o += -Wno-missing-field-initializers
> endif
> endif
> endif
> --
> 2.6.4
>
On Fri, 4 May 2018 16:38:03 -0500
Erik Gabriel Carrillo <erik.g.carrillo@intel.com> wrote:
> Build errors occur on CentOS 7 with GCC 4.8.5 20150623 in the
> event_timer_adapter_test autotest; the
> -Werror=missing-field-initializers option causes the compiler to emit
> messages like "error: missing initializer for field ‘priority’ of
> ‘struct <anonymous>’" in several places.
>
> Add -Wno-missing-field-initializers to the test's CFLAGS to allow the
> current syntax if we are using GCC 5.0 or lower.
>
> Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> ---
> test/test/Makefile | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/test/test/Makefile b/test/test/Makefile
> index 2630ab4..2011857 100644
> --- a/test/test/Makefile
> +++ b/test/test/Makefile
> @@ -211,6 +211,7 @@ CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
> # designated initializers.
> ifeq ($(shell test $(GCC_VERSION) -le 50 && echo 1), 1)
> CFLAGS_test_eventdev_sw.o += -Wno-missing-field-initializers
> +CFLAGS_test_event_timer_adapter.o += -Wno-missing-field-initializers
> endif
> endif
> endif
Why not fix the code rather than supressing the warning??
> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, May 4, 2018 11:55 PM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: jerin.jacob@caviumnetworks.com; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v1 1/1] test: fix build with GCC 4.8.5
>
> On Fri, 4 May 2018 16:38:03 -0500
> Erik Gabriel Carrillo <erik.g.carrillo@intel.com> wrote:
>
> > Build errors occur on CentOS 7 with GCC 4.8.5 20150623 in the
> > event_timer_adapter_test autotest; the
> > -Werror=missing-field-initializers option causes the compiler to emit
> > messages like "error: missing initializer for field ‘priority’ of
> > ‘struct <anonymous>’" in several places.
> >
> > Add -Wno-missing-field-initializers to the test's CFLAGS to allow the
> > current syntax if we are using GCC 5.0 or lower.
> >
> > Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> > ---
> > test/test/Makefile | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/test/test/Makefile b/test/test/Makefile index
> > 2630ab4..2011857 100644
> > --- a/test/test/Makefile
> > +++ b/test/test/Makefile
> > @@ -211,6 +211,7 @@ CFLAGS_test_memcpy_perf.o +=
> > -fno-var-tracking-assignments # designated initializers.
> > ifeq ($(shell test $(GCC_VERSION) -le 50 && echo 1), 1)
> > CFLAGS_test_eventdev_sw.o += -Wno-missing-field-initializers
> > +CFLAGS_test_event_timer_adapter.o += -Wno-missing-field-initializers
> > endif
> > endif
> > endif
>
> Why not fix the code rather than supressing the warning??
The -Wmissing-field-initializers option is supposed to not warn about designated initializers:
https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Warning-Options.html#index-Wmissing-field-initializers-473
The code being flagged uses designated initializers, but the structures being initialized contain anonymous structs, and -Wmissing-field-initializers seems to not handle this properly in GCC 4.8.5. In fact, it emits false positives about members that were explicitly initialized, and omits warnings about some that weren't.
Since designated initializers should be allowed, and the proposed fix only suppresses the one warning in few cases, I think it makes sense.
@@ -211,6 +211,7 @@ CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
# designated initializers.
ifeq ($(shell test $(GCC_VERSION) -le 50 && echo 1), 1)
CFLAGS_test_eventdev_sw.o += -Wno-missing-field-initializers
+CFLAGS_test_event_timer_adapter.o += -Wno-missing-field-initializers
endif
endif
endif