X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsystemctl%2Fsystemctl.c;h=edd136addddf9bd10dbdfe8ab29c3f568c71f5a0;hb=4ad61fd1806dde23d2c99043b4bed91a196d2c82;hp=5902a3798df7e7d7583ded65ce6b992266a93d36;hpb=886a64fe6903bc1ccde5c7af0eac6786918c8e49;p=elogind.git diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 5902a3798..edd136add 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2053,7 +2053,7 @@ static int set_cgroup_attr(DBusConnection *bus, char **args) { } static int get_cgroup_attr(DBusConnection *bus, char **args) { - _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL; + _cleanup_dbus_message_unref_ DBusMessage *reply = NULL; _cleanup_free_ char *n = NULL; char **argument; int r; @@ -4918,7 +4918,7 @@ static int parse_argv(int argc, char *argv[]) { * request to it. For now we simply * guess that it is Upstart. */ - execv("/lib/upstart/telinit", argv); + execv(TELINIT, argv); log_error("Couldn't find an alternative telinit implementation to spawn."); return -EIO; @@ -5041,21 +5041,22 @@ finish: } static int talk_initctl(void) { - struct init_request request; - int r, fd; + struct init_request request = {0}; + int r; + int _cleanup_close_ fd = -1; char rl; - if (!(rl = action_to_runlevel())) + rl = action_to_runlevel(); + if (!rl) return 0; - zero(request); request.magic = INIT_MAGIC; request.sleeptime = 0; request.cmd = INIT_CMD_RUNLVL; request.runlevel = rl; - if ((fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY)) < 0) { - + fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY); + if (fd < 0) { if (errno == ENOENT) return 0; @@ -5065,9 +5066,7 @@ static int talk_initctl(void) { errno = 0; r = loop_write(fd, &request, sizeof(request), false) != sizeof(request); - close_nointr_nofail(fd); - - if (r < 0) { + if (r) { log_error("Failed to write to "INIT_FIFO": %m"); return errno ? -errno : -EIO; }