return 0;
}
-static void context_done(Context *c) {
- assert(c);
-
- (void) unmute_pid1(c);
- (void) unmute_kernel(c);
-
- if (c->link) {
- (void) sd_varlink_set_userdata(c->link, NULL);
- c->link = sd_varlink_flush_close_unref(c->link);
- }
-}
-
-static Context* context_free(Context *c) {
- if (!c)
- return NULL;
-
- context_done(c);
- return mfree(c);
-}
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(Context*, context_free);
-
static void vl_on_disconnect(sd_varlink_server *server, sd_varlink *link, void *userdata) {
assert(link);
if (!c)
return;
- context_free(c);
+ (void) unmute_pid1(c);
+ (void) unmute_kernel(c);
+
+ (void) sd_varlink_set_userdata(c->link, NULL);
+ sd_varlink_flush_close_unref(c->link);
+
+ free(c);
}
static int vl_method_mute(
assert(link);
- _cleanup_(context_freep) Context *nc = new(Context, 1);
+ _cleanup_free_ Context *nc = new(Context, 1);
if (!nc)
return -ENOMEM;
if (!arg_mute_pid1 && !arg_mute_kernel)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not asked to mute anything, refusing.");
- _cleanup_(context_done) Context c = {
+ Context c = {
.mute_pid1 = arg_mute_pid1,
.mute_kernel = arg_mute_kernel,
.saved_kernel = -1,