linux-user: Fix a pair of -Wextra warnings
cover linux-user: Fix a pair of -Wextra warnings
Philippe Mathieu-Daudé (2):
linux-user/syscall: Silent -Wmissing-field-initializers warnings linux-user/signal: Silent -Winitializer-overrides warnings
linux-user/signal-common.h | 2 +- linux-user/syscall.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/2 linux-user/syscall: Silent -Wmissing-field-initializers warnings
Silent when compiling with -Wextra:
In file included from ../../linux-user/syscall.c:5742:
../linux-user/ioctls.h:694:3: warning: missing field 'access' initializer [-Wmissing-field-initializers] IOCTL_IGNORE(TIOCSTART)
^
../linux-user/syscall.c:5741:31: note: expanded from macro 'IOCTL_IGNORE'
{ TARGET_ ## cmd, 0, #cmd },
^
../linux-user/syscall.c:5743:13: warning: missing field 'name' initializer [-Wmissing-field-initializers]
{ 0, 0, },
^
../linux-user/syscall.c:12949:44: warning: missing field 'sigev_signo' initializer [-Wmissing-field-initializers]
struct sigevent host_sevp = { {0}, }, *phost_sevp = NULL;
^--- linux-user/syscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
linux-user/syscall.c +5 -5
@@ -5738,9 +5738,9 @@ IOCTLEntry ioctl_entries[] = {#define IOCTL_SPECIAL (cmd, access, dofn, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, dofn, { __VA_ARGS__ } },#define IOCTL_IGNORE (cmd) \ - { TARGET_ ## cmd, 0, #cmd }, + { TARGET_ ## cmd, 0, #cmd, 0, NULL, { } },#include "ioctls.h" - { 0, 0, }, + {/* end of list */ } };/* ??? Implement proper locking for ioctls. */
@@ -12946,7 +12946,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, {/* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */ -struct sigevent host_sevp = { {0 }, }, *phost_sevp =NULL ; +struct sigevent host_sevp = { }, *phost_sevp =NULL ;int clkid = arg1;int timer_index =next_free_host_timer ();
@@ -12993,7 +12993,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, ret = -TARGET_EINVAL ; }else {timer_t htimer = g_posix_timers[timerid]; -struct itimerspec hspec_new = {{0 },}, hspec_old = {{0 },}; +struct itimerspec hspec_new = { }, hspec_old = { };if (target_to_host_itimerspec (&hspec_new, arg3)) {return -TARGET_EFAULT ;
@@ -13019,7 +13019,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, ret = -TARGET_EINVAL ; }else {timer_t htimer = g_posix_timers[timerid]; -struct itimerspec hspec_new = {{0 },}, hspec_old = {{0 },}; +struct itimerspec hspec_new = { }, hspec_old = { };if (target_to_host_itimerspec64 (&hspec_new, arg3)) {return -TARGET_EFAULT ;
Signature · 1 line
2.38.1
PATCH 2/2 linux-user/signal: Silent -Winitializer-overrides warnings
In reply to Philippe Mathieu-Daudé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
^--- linux-user/signal-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/signal-common.h +1 -1
@@ -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
Signature · 1 line
2.38.1
Re: [PATCH 2/2] linux-user/signal: Silent -Winitializer-overrides warnings
Quoted 39 lines · Philippe Mathieu-Daudé
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é <[email protected]>--- linux-user/signal-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/signal-common.h +0
-0
linux-user/signal-common.h static inline void finish_sigsuspend_mask(int ret) · line 130
Quoted 8 lines
linux-user/signal-common.h +1
-1@@ -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