]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Merge pull request #2534 from tcharding/checkpatch
authorChristian Brauner <christian@brauner.io>
Thu, 16 Aug 2018 08:40:10 +0000 (10:40 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Aug 2018 08:40:10 +0000 (10:40 +0200)
Checkpatch

1  2 
src/lxc/cmd/lxc_usernsexec.c

index 107668273f0beb88eda548b39bb73d9aac96d1ea,69ba7a41e162c03116a3e3119a520cbbda6c4c0f..227b79212d3aa7d9d136be86aa26fb848d4e9b20
@@@ -333,18 -333,18 +333,18 @@@ int main(int argc, char *argv[]
  
        while ((c = getopt(argc, argv, "m:h")) != EOF) {
                switch (c) {
-                       case 'm':
-                               if (parse_map(optarg)) {
-                                       usage(argv[0]);
-                                       exit(EXIT_FAILURE);
-                               }
-                               break;
-                       case 'h':
-                                 usage(argv[0]);
-                                 exit(EXIT_SUCCESS);
-                       default:
-                                 usage(argv[0]);
-                                 exit(EXIT_FAILURE);
+               case 'm':
+                       if (parse_map(optarg)) {
+                               usage(argv[0]);
+                               exit(EXIT_FAILURE);
+                       }
+                       break;
+               case 'h':
+                       usage(argv[0]);
+                       exit(EXIT_SUCCESS);
+               default:
+                       usage(argv[0]);
+                       exit(EXIT_FAILURE);
                }
        };
  
                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);
  
                ret = unshare(flags);
                if (ret < 0) {
 -                      perror("unshare");
 +                      fprintf(stderr,
 +                              "Failed to unshare mount and user namespace\n");
                        return 1;
                }
                buf[0] = '1';
  
                close(pipe_fds1[1]);
                close(pipe_fds2[0]);
-               return do_child((void*)argv);
+               return do_child((void *)argv);
        }
  
        close(pipe_fds1[1]);
        close(pipe_fds2[0]);
 -      if (lxc_read_nointr(pipe_fds1[0], buf, 1) < 1) {
 +      ret = lxc_read_nointr(pipe_fds1[0], buf, 1);
 +      if (ret < 0) {
                perror("read pipe");
                exit(EXIT_FAILURE);
 +      } else if (ret == 0) {
 +              fprintf(stderr, "Failed to read from pipe\n");
 +              exit(EXIT_FAILURE);
        }
  
        buf[0] = '1';
                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);
        }