From 46c9bcd6a47bdaa70869ed64da315315974b8b1d Mon Sep 17 00:00:00 2001 From: Ben Gamari <ben@smart-cactus.org> Date: Thu, 29 Jun 2023 10:27:51 -0400 Subject: [PATCH] rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. --- rts/posix/Signals.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c index a16bc24b7cac..2d31b46a618e 100644 --- a/rts/posix/Signals.c +++ b/rts/posix/Signals.c @@ -368,9 +368,11 @@ int stg_sig_install(int sig, int spi, void *mask) { sigset_t signals, osignals; - struct sigaction action; StgInt previous_spi; + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); + ACQUIRE_LOCK(&sig_mutex); // Block the signal until we figure out what to do @@ -619,6 +621,7 @@ static void set_sigtstp_action (bool handle) { struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); if (handle) { sa.sa_handler = sigtstp_handler; } else { @@ -635,7 +638,8 @@ set_sigtstp_action (bool handle) void install_vtalrm_handler(int sig, TickProc handle_tick) { - struct sigaction action = {}; + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); action.sa_handler = handle_tick; @@ -677,8 +681,11 @@ install_vtalrm_handler(int sig, TickProc handle_tick) void initDefaultHandlers(void) { - struct sigaction action = {}; - struct sigaction oact = {}; + // N.B. We can't use initializers here as CentOS's ancient toolchain throws + // spurious warnings. See #23577. + struct sigaction action, oact; + memset(&oact, 0, sizeof(struct sigaction)); + memset(&action, 0, sizeof(struct sigaction)); // install the SIGINT handler action.sa_handler = shutdown_handler; -- GitLab