]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: cleanup macros lxc_cmd_init()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 17 Feb 2019 13:46:25 +0000 (14:46 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 18 Feb 2019 14:24:14 +0000 (15:24 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index 212191743ea426403a6887f778a7d48f99364d67..f4304e6404256f358b26e0217de42977b9dcf7bf 100644 (file)
@@ -1220,14 +1220,15 @@ int lxc_cmd_init(const char *name, const char *lxcpath, const char *suffix)
 int lxc_cmd_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
                         struct lxc_handler *handler)
 {
+       __do_close_prot_errno int fd = handler->conf->maincmd_fd;
        int ret;
-       int fd = handler->conf->maincmd_fd;
 
        ret = lxc_mainloop_add_handler(descr, fd, lxc_cmd_accept, handler);
        if (ret < 0) {
                ERROR("Failed to add handler for command socket");
-               close(fd);
+               return ret;
        }
 
+       steal_fd(fd);
        return ret;
 }