From: Zbigniew Jędrzejewski-Szmek Date: Thu, 18 Aug 2022 13:06:00 +0000 (+0200) Subject: sd-netlink: simplify error code retention X-Git-Tag: v252-rc1~394^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40c864afe0d281e0cba5a2d77d1d8adb15724604;p=thirdparty%2Fsystemd.git sd-netlink: simplify error code retention --- diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index 965235862cd..9a88285d09a 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -539,7 +539,7 @@ _public_ int sd_netlink_call_async( } } - /* Set this at last. Otherwise, some failures in above call the destroy callback but some do not. */ + /* Set this at last. Otherwise, some failures in above would call destroy_callback but some would not. */ slot->destroy_callback = destroy_callback; if (ret_slot) @@ -705,32 +705,30 @@ static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) { static int prepare_callback(sd_event_source *s, void *userdata) { sd_netlink *nl = userdata; - int r, e; + int r, enabled; usec_t until; assert(s); assert(nl); - e = sd_netlink_get_events(nl); - if (e < 0) - return e; - - r = sd_event_source_set_io_events(nl->io_event_source, e); + r = sd_netlink_get_events(nl); if (r < 0) return r; - r = sd_netlink_get_timeout(nl, &until); + r = sd_event_source_set_io_events(nl->io_event_source, r); if (r < 0) return r; - if (r > 0) { - int j; - j = sd_event_source_set_time(nl->time_event_source, until); - if (j < 0) - return j; + enabled = sd_netlink_get_timeout(nl, &until); + if (enabled < 0) + return enabled; + if (enabled > 0) { + r = sd_event_source_set_time(nl->time_event_source, until); + if (r < 0) + return r; } - r = sd_event_source_set_enabled(nl->time_event_source, r > 0); + r = sd_event_source_set_enabled(nl->time_event_source, enabled > 0); if (r < 0) return r;