From 6c8763dcb5607dab8d4371f4c72d85edc083f8f9 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Thu, 20 Nov 2025 12:50:02 +0530 Subject: [PATCH] daemon: modernize pulse_mode_cancel with compound literals Signed-off-by: Susant Sahani --- daemon/proto.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/daemon/proto.c b/daemon/proto.c index 32e3d287b..c4940219b 100644 --- a/daemon/proto.c +++ b/daemon/proto.c @@ -707,22 +707,14 @@ void pulse_mode_cancel (void) { const int err = errno; /* Function must preserve errno. */ - struct itimerval it; - struct sigaction act; /* Setting it_value to zero cancels the itimer. */ - it.it_value.tv_sec = 0; - it.it_value.tv_usec = 0; - it.it_interval.tv_sec = 0; - it.it_interval.tv_usec = 0; + if (setitimer (ITIMER_REAL, + &(struct itimerval){ .it_value = { 0 } }, + NULL) == -1) + perror("pulse_mode_cancel: setitimer"); - if (setitimer (ITIMER_REAL, &it, NULL) == -1) - perror ("pulse_mode_cancel: setitimer"); - - memset (&act, 0, sizeof act); - act.sa_handler = SIG_DFL; - - if (sigaction (SIGALRM, &act, NULL) == -1) + if (sigaction (SIGALRM, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL)) perror ("pulse_mode_cancel: sigaction"); errno = err;