zfcpdump: Fix incompatible cast compile warning

When zfcpdump is built you get a compile warning

zfcpdump.c: In function ‘init_sig’:
zfcpdump.c:307:24: warning: cast between incompatible function types from ‘void (* (*)(int,  siginfo_t *, void *))(int)’ {aka ‘void (* (*)(int,  struct <anonymous> *, void *))(int)’} to ‘void (*)(int)’ [-Wcast-function-type]
  g.sigact.sa_handler = (__sighandler_t)dump_sig_handler;

Furthermore the man pages for sigaction says

$man 2 sigaction
[...]
       If SA_SIGINFO is specified in sa_flags, then sa_sigaction (instead
       of sa_handler) specifies the signal-handling function for signum.
       This function receives three arguments, as described below.
[...]

Because SA_SIGINFO is set, using sa_handler at all is wrong in this case.

Fix this by giving dump_sig_handler the correct return type and assign it
to sa_sigaction.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Philipp Rudo
2018-07-31 12:16:57 +02:00
committed by Jan Höppner
parent f02de298c1
commit cb3e949772

View File

@@ -288,12 +288,10 @@ no_reipl:
/*
* Signal handler for zfcp_dumper
*/
static __sighandler_t dump_sig_handler(int sig, siginfo_t *UNUSED(sip),
void *UNUSED(p))
static void dump_sig_handler(int sig, siginfo_t *UNUSED(sip), void *UNUSED(p))
{
PRINT_ERR("Got signal: %i\n", sig);
terminate(1);
return NULL;
}
/*
@@ -304,7 +302,7 @@ static __sighandler_t dump_sig_handler(int sig, siginfo_t *UNUSED(sip),
static int init_sig(void)
{
g.sigact.sa_flags = (SA_NODEFER | SA_SIGINFO | SA_RESETHAND);
g.sigact.sa_handler = (__sighandler_t)dump_sig_handler;
g.sigact.sa_sigaction = dump_sig_handler;
if (sigemptyset(&g.sigact.sa_mask) < 0)
return -1;
if (sigaction(SIGINT, &g.sigact, NULL) < 0)