]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc init: coding style 2267/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Apr 2018 18:44:14 +0000 (20:44 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Apr 2018 18:44:14 +0000 (20:44 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cmd/lxc_init.c

index 9168c7878c61e41f804ef9417e79de0bd2ed351d..228a2eb8bca84c2db2f421ebc90b27a055af03b7 100644 (file)
@@ -100,7 +100,6 @@ static struct arguments my_args = {
 static void prevent_forking(void)
 {
        FILE *f;
-       int fd = -1;
        size_t len = 0;
        char *line = NULL;
        char path[MAXPATHLEN];
@@ -110,7 +109,7 @@ static void prevent_forking(void)
                return;
 
        while (getline(&line, &len, f) != -1) {
-               int ret;
+               int fd, ret;
                char *p, *p2;
 
                p = strchr(line, ':');
@@ -146,7 +145,8 @@ static void prevent_forking(void)
                        goto on_error;
                }
 
-               if (write(fd, "1", 1) != 1)
+               ret = write(fd, "1", 1);
+               if (ret != 1)
                        SYSERROR("Failed to write to \"%s\"", path);
 
                close(fd);