From: Lennart Poettering Date: Tue, 2 Apr 2019 09:51:50 +0000 (+0200) Subject: logind: simplify removal of device fds X-Git-Tag: v242-rc1~8^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=883d1b01b0d2ec0e396221ff0c977aec7f555ecf;p=thirdparty%2Fsystemd.git logind: simplify removal of device fds let's use sd_notifyf(). Let's also stop validating the session ID here. This is the destructor. if it contains a dash, we are already too late here anyway. --- diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index f358524ebca..7c79a4afdcf 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -387,21 +387,11 @@ void session_device_free(SessionDevice *sd) { assert(sd); /* Make sure to remove the pushed fd. */ - if (sd->pushed_fd) { - _cleanup_free_ char *m = NULL; - const char *id; - int r; - - /* Session ID does not contain separators. */ - id = sd->session->id; - assert(*(id + strcspn(id, "-\n")) == '\0'); - - r = asprintf(&m, "FDSTOREREMOVE=1\n" - "FDNAME=session-%s-device-%u-%u\n", - id, major(sd->dev), minor(sd->dev)); - if (r >= 0) - (void) sd_notify(false, m); - } + if (sd->pushed_fd) + (void) sd_notifyf(false, + "FDSTOREREMOVE=1\n" + "FDNAME=session-%s-device-%u-%u", + sd->session->id, major(sd->dev), minor(sd->dev)); session_device_stop(sd); session_device_notify(sd, SESSION_DEVICE_RELEASE);