summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@gmail.com>2020-02-12 20:51:44 +0100
committerBenjamin Franzke <benjaminfranzke@gmail.com>2020-02-15 11:07:11 +0100
commitf51873b65cb766eb7ade752de912f1ddaf640456 (patch)
treea004e6c0816ad39d490e14c5468ad25d631c375b /src
parentdafca5f4a287d04eaf5e886a07f7f341a9a02456 (diff)
downloadpa-sink-ctl-f51873b65cb766eb7ade752de912f1ddaf640456.tar.gz
pa-sink-ctl-f51873b65cb766eb7ade752de912f1ddaf640456.tar.bz2
pa-sink-ctl-f51873b65cb766eb7ade752de912f1ddaf640456.zip
unix_signal: Fix warnings and notes
Doesn't happen on linux, as we have signalfd there, but would be triggered for other operating systems. warning: missing braces around initializer [-Wmissing-braces] sigaction(signum, &(struct sigaction){handler}, NULL); ^ unix_signal.c:130:39: note: (near initialization for '(anonymous)') unix_signal.c:130:29: warning: missing initializer for field 'sa_mask' of 'struct sigaction' [-Wmissing-field-initializers] sigaction(signum, &(struct sigaction){handler}, NULL); ^
Diffstat (limited to 'src')
-rw-r--r--src/unix_signal.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/unix_signal.c b/src/unix_signal.c
index 5eaa482..17c8725 100644
--- a/src/unix_signal.c
+++ b/src/unix_signal.c
@@ -34,6 +34,16 @@ typedef struct _UnixSignalSource {
UnixSignalData *data;
} UnixSignalSource;
+static void
+handler(gint signum);
+
+struct sigaction act_handler = {
+ .sa_handler = handler
+};
+struct sigaction act_null = {
+ .sa_handler = NULL
+};
+
static inline UnixSignalData *
unix_signal_data(guint index)
{
@@ -47,7 +57,7 @@ handler(gint signum)
for (guint i = 0; i < signal_data->len; ++i)
if (unix_signal_data(i)->signum == signum)
unix_signal_data(i)->triggered = TRUE;
- sigaction(signum, &(struct sigaction){handler}, NULL);
+ sigaction(signum, &act_handler, NULL);
}
static gboolean
@@ -89,7 +99,7 @@ finalize(GSource *source)
{
UnixSignalSource *signal_source = (UnixSignalSource*) source;
- sigaction(signal_source->data->signum, &(struct sigaction){NULL}, NULL);
+ sigaction(signal_source->data->signum, &act_null, NULL);
g_main_context_unref(signal_source->data->context);
g_ptr_array_remove_fast(signal_data, signal_source->data);
if (signal_data->len == 0)
@@ -127,7 +137,7 @@ unix_signal_source_new(gint signum)
GSource *source = g_source_new(&SourceFuncs, sizeof(UnixSignalSource));
unix_signal_source_init(source, signum);
- sigaction(signum, &(struct sigaction){handler}, NULL);
+ sigaction(signum, &act_handler, NULL);
return source;
}