From: Tobin C. Harding Date: Thu, 16 Aug 2018 07:04:58 +0000 (+1000) Subject: cmd: Move assignment out of if statement X-Git-Tag: lxc-3.1.0~158^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2534%2Fhead;p=thirdparty%2Flxc.git cmd: Move assignment out of if statement checkpatch.pl emits error ERROR: do not use assignment in if condition Move assignment out of if statement. Signed-off-by: Tobin C. Harding --- diff --git a/src/lxc/cmd/lxc_usernsexec.c b/src/lxc/cmd/lxc_usernsexec.c index 268ec9341..69ba7a41e 100644 --- a/src/lxc/cmd/lxc_usernsexec.c +++ b/src/lxc/cmd/lxc_usernsexec.c @@ -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); }