From 02c51d4231da154b624fe5859a1e34f340eecb05 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Sep 2015 13:26:58 +0200 Subject: [PATCH] systemd/adapt: assert that a @source argument is passed to sd_event_add_time() Systemd supports omitting the output source argument. In this case, the created event source is floating and the reference count is handled properly. We have however no callers that make use of that functionality, so instead of implementing floating references, assert that we don't need it. This isn't a change in behavior, because previously the could would just SEGFAULT if a caller didn't want to take ownership of the created event. --- src/systemd/nm-sd-adapt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/systemd/nm-sd-adapt.c b/src/systemd/nm-sd-adapt.c index 67ddc8da1b..1f8f2dcc3e 100644 --- a/src/systemd/nm-sd-adapt.c +++ b/src/systemd/nm-sd-adapt.c @@ -125,6 +125,10 @@ sd_event_add_io (sd_event *e, sd_event_source **s, int fd, uint32_t events, sd_e GIOChannel *channel; GIOCondition condition = 0; + /* systemd supports floating sd_event_source by omitting the @s argument. + * We don't have such users and don't implement floating references. */ + g_return_val_if_fail (s, -EINVAL); + channel = g_io_channel_unix_new (fd); if (!channel) return -EINVAL; @@ -179,6 +183,10 @@ sd_event_add_time(sd_event *e, sd_event_source **s, clockid_t clock, uint64_t us struct sd_event_source *source; uint64_t n = now (clock); + /* systemd supports floating sd_event_source by omitting the @s argument. + * We don't have such users and don't implement floating references. */ + g_return_val_if_fail (s, -EINVAL); + source = source_new (); source->time_cb = callback; source->user_data = userdata;