]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cmd: Move assignment out of if statement 2534/head
authorTobin C. Harding <me@tobin.cc>
Thu, 16 Aug 2018 07:04:58 +0000 (17:04 +1000)
committerTobin C. Harding <me@tobin.cc>
Thu, 16 Aug 2018 07:06:20 +0000 (17:06 +1000)
checkpatch.pl emits error

    ERROR: do not use assignment in if condition

Move assignment out of if statement.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
src/lxc/cmd/lxc_usernsexec.c

index 268ec9341f3aa2c7f37fad450d3672ddf206c3dd..69ba7a41e162c03116a3e3119a520cbbda6c4c0f 100644 (file)
@@ -364,9 +364,8 @@ int main(int argc, char *argv[])
                perror("pipe");
                exit(EXIT_FAILURE);
        }
-       if ((pid = fork()) == 0) {
-               /* Child. */
-
+       pid = fork();
+       if (pid == 0) { /* Child. */
                close(pipe_fds1[0]);
                close(pipe_fds2[1]);
                opentty(ttyname0, 0);
@@ -413,8 +412,8 @@ int main(int argc, char *argv[])
                perror("write to pipe");
                exit(EXIT_FAILURE);
        }
-
-       if ((ret = waitpid(pid, &status, __WALL)) < 0) {
+       ret = waitpid(pid, &status, __WALL);
+       if (ret < 0) {
                printf("waitpid() returns %d, errno %d\n", ret, errno);
                exit(EXIT_FAILURE);
        }