diff mbox series

[2/2] linux-user/signal: Silent -Winitializer-overrides warnings

Message ID 20221220144219.25254-3-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series linux-user: Fix a pair of -Wextra warnings | expand

Commit Message

Philippe Mathieu-Daudé Dec. 20, 2022, 2:42 p.m. UTC
The target SIGIOT signal is sometimes aliased with SIGABRT,
producing the following warning when compiling with -Wextra:

  ../linux-user/signal.c:57:9: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
          MAKE_SIGNAL_LIST
          ^~~~~~~~~~~~~~~~
  ../linux-user/signal-common.h:165:9: note: expanded from macro 'MAKE_SIGNAL_LIST'
          MAKE_SIG_ENTRY_SIGIOT
          ^~~~~~~~~~~~~~~~~~~~~
  ../linux-user/signal-common.h:128:41: note: expanded from macro 'MAKE_SIG_ENTRY_SIGIOT'
  #define MAKE_SIG_ENTRY_SIGIOT           MAKE_SIG_ENTRY(SIGIOT)
                                          ^~~~~~~~~~~~~~~~~~~~~~
  ../linux-user/signal.c:56:41: note: expanded from macro 'MAKE_SIG_ENTRY'
  #define MAKE_SIG_ENTRY(sig)     [sig] = TARGET_##sig,
                                          ^~~~~~~~~~~~
  <scratch space>:81:1: note: expanded from here
  TARGET_SIGIOT
  ^~~~~~~~~~~~~
  ../linux-user/sh4/../generic/signal.h:26:34: note: expanded from macro 'TARGET_SIGIOT'
  #define TARGET_SIGIOT            6
                                   ^
  <scratch space>:55:1: note: expanded from here
  TARGET_SIGABRT
  ^~~~~~~~~~~~~~
  ../linux-user/sh4/../generic/signal.h:25:34: note: expanded from macro 'TARGET_SIGABRT'
  #define TARGET_SIGABRT           6
                                   ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 linux-user/signal-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell Dec. 20, 2022, 3:47 p.m. UTC | #1
On Tue, 20 Dec 2022 at 14:43, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> The target SIGIOT signal is sometimes aliased with SIGABRT,
> producing the following warning when compiling with -Wextra:
>
>   ../linux-user/signal.c:57:9: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
>           MAKE_SIGNAL_LIST
>           ^~~~~~~~~~~~~~~~
>   ../linux-user/signal-common.h:165:9: note: expanded from macro 'MAKE_SIGNAL_LIST'
>           MAKE_SIG_ENTRY_SIGIOT
>           ^~~~~~~~~~~~~~~~~~~~~
>   ../linux-user/signal-common.h:128:41: note: expanded from macro 'MAKE_SIG_ENTRY_SIGIOT'
>   #define MAKE_SIG_ENTRY_SIGIOT           MAKE_SIG_ENTRY(SIGIOT)
>                                           ^~~~~~~~~~~~~~~~~~~~~~
>   ../linux-user/signal.c:56:41: note: expanded from macro 'MAKE_SIG_ENTRY'
>   #define MAKE_SIG_ENTRY(sig)     [sig] = TARGET_##sig,
>                                           ^~~~~~~~~~~~
>   <scratch space>:81:1: note: expanded from here
>   TARGET_SIGIOT
>   ^~~~~~~~~~~~~
>   ../linux-user/sh4/../generic/signal.h:26:34: note: expanded from macro 'TARGET_SIGIOT'
>   #define TARGET_SIGIOT            6
>                                    ^
>   <scratch space>:55:1: note: expanded from here
>   TARGET_SIGABRT
>   ^~~~~~~~~~~~~~
>   ../linux-user/sh4/../generic/signal.h:25:34: note: expanded from macro 'TARGET_SIGABRT'
>   #define TARGET_SIGABRT           6
>                                    ^
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  linux-user/signal-common.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
> index 3e2dc604c2..a168ea4851 100644
> --- a/linux-user/signal-common.h
> +++ b/linux-user/signal-common.h
> @@ -124,7 +124,7 @@ static inline void finish_sigsuspend_mask(int ret)
>  #define MAKE_SIG_ENTRY_SIGSTKFLT
>  #endif
>
> -#if defined(SIGIOT) && defined(TARGET_SIGIOT)
> +#if defined(SIGIOT) && defined(TARGET_SIGIOT) && TARGET_SIGABRT != TARGET_SIGIOT
>  #define MAKE_SIG_ENTRY_SIGIOT           MAKE_SIG_ENTRY(SIGIOT)
>  #else
>  #define MAKE_SIG_ENTRY_SIGIOT

This suppresses the array entry in the case where TARGET_SIGABRT ==
TARGET_SIGIOT,
but the compiler error is I think complaining about the case where
host SIGABRT == SIGIOT.

The MAKE_SIG_ENTRY macros are used to construct both the host-to-target signal
table in signal.c and also a target-signal-to-string table in strace.c;
so whether you want to check "target signals the same?" or "host signals
the same?" to suppress the overriding entry varies depending on which table.

However, this is all a bit moot because:
 (1) we deliberately do not enable the -Winitializer-overrides
     warning, because it produces false positives on the various
     cases where we want to use the coding pattern "initialize a range
     first, then override some specific members within it"
 (2) There is no Linux architecture where SIGIOT is not a synonym
     for SIGABRT, so the right thing to do here is just to
     delete MAKE_SIG_ENTRY_SIGIOT entirely.

thanks
-- PMM
diff mbox series

Patch

diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
index 3e2dc604c2..a168ea4851 100644
--- a/linux-user/signal-common.h
+++ b/linux-user/signal-common.h
@@ -124,7 +124,7 @@  static inline void finish_sigsuspend_mask(int ret)
 #define MAKE_SIG_ENTRY_SIGSTKFLT
 #endif
 
-#if defined(SIGIOT) && defined(TARGET_SIGIOT)
+#if defined(SIGIOT) && defined(TARGET_SIGIOT) && TARGET_SIGABRT != TARGET_SIGIOT
 #define MAKE_SIG_ENTRY_SIGIOT           MAKE_SIG_ENTRY(SIGIOT)
 #else
 #define MAKE_SIG_ENTRY_SIGIOT