[PATCH 2/2] Ignore missing braces error for GCC 4.9 or older
Florian Weimer
fw@deneb.enyo.de
Sun Dec 15 13:00:17 GMT 2024
* H. J. Lu:
> Since not all targets need braces, ignore missing braces error for GCC
> 4.9 or older:
>
> tst-system.c: In function ‘sleep_and_check_sigchld’:
> tst-system.c:83:3: error: missing braces around initializer [-Werror=missing-braces]
> sigset_t blocked = {0};
> ^
> tst-system.c:83:3: error: (near initialization for ‘blocked.__val’) [-Werror=missing-braces]
> cc1: all warnings being treated as errors
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
> posix/tst-spawn7.c | 15 +++++++++++++++
> rt/tst-timer-sigmask.c | 15 +++++++++++++++
> stdlib/tst-system.c | 8 ++++++++
> sysdeps/pthread/tst-cancel28.c | 15 +++++++++++++++
> 4 files changed, 53 insertions(+)
>
> diff --git a/posix/tst-spawn7.c b/posix/tst-spawn7.c
> index e4adc6cbf0..14b755081c 100644
> --- a/posix/tst-spawn7.c
> +++ b/posix/tst-spawn7.c
> @@ -27,6 +27,7 @@
> #include <sys/wait.h>
> #include <unistd.h>
> #include <tst-spawn.h>
> +#include <libc-diag.h>
>
> /* Nonzero if the program gets called via `exec'. */
> #define CMDLINE_OPTIONS \
> @@ -114,7 +115,14 @@ do_test_signals (void)
> {
> /* Same as before, but set SIGUSR1 and SIGUSR2 to a handler different than
> SIG_IGN or SIG_DFL. */
> +#if !__GNUC_PREREQ (5, 0)
> + DIAG_PUSH_NEEDS_COMMENT;
> + DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmissing-braces");
> +#endif
> struct sigaction sa = { 0 };
> +#if !__GNUC_PREREQ (5, 0)
> + DIAG_POP_NEEDS_COMMENT;
> +#endif
Why not write “= { }” instead? That GCC extension is quite old?
If we want to get the test sources to compile without any GCC
extensions, that's going to be a much larger effort.
More information about the Libc-alpha
mailing list