]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Move code/variable in smaller scope
authorRachid Koucha <47061324+Rachid-Koucha@users.noreply.github.com>
Sat, 29 Jun 2019 21:21:14 +0000 (23:21 +0200)
committerGitHub <noreply@github.com>
Sat, 29 Jun 2019 21:21:14 +0000 (23:21 +0200)
In start.c, do not fill path[] table if not necessary

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
src/lxc/start.c

index eaec20f9648386705b49f90d55c7679644a3c03e..0842dc35429805ffb30de8fb25ae3dcb51fa8ad5 100644 (file)
@@ -1132,7 +1132,6 @@ static int do_start(void *data)
        ATTR_UNUSED __do_close_prot_errno int data_sock0 = handler->data_sock[0],
                                              data_sock1 = handler->data_sock[1];
        int ret;
        ATTR_UNUSED __do_close_prot_errno int data_sock0 = handler->data_sock[0],
                                              data_sock1 = handler->data_sock[1];
        int ret;
-       char path[PATH_MAX];
        uid_t new_uid;
        gid_t new_gid;
        struct lxc_list *iterator;
        uid_t new_uid;
        gid_t new_gid;
        struct lxc_list *iterator;
@@ -1239,11 +1238,6 @@ static int do_start(void *data)
                goto out_warn_father;
        }
 
                goto out_warn_father;
        }
 
-       ret = snprintf(path, sizeof(path), "%s/dev/null",
-                      handler->conf->rootfs.mount);
-       if (ret < 0 || ret >= sizeof(path))
-               goto out_warn_father;
-
        /* In order to checkpoint restore, we need to have everything in the
         * same mount namespace. However, some containers may not have a
         * reasonable /dev (in particular, they may not have /dev/null), so we
        /* In order to checkpoint restore, we need to have everything in the
         * same mount namespace. However, some containers may not have a
         * reasonable /dev (in particular, they may not have /dev/null), so we
@@ -1255,6 +1249,13 @@ static int do_start(void *data)
         * where it isn't wanted.
         */
        if (handler->daemonize && !handler->conf->autodev) {
         * where it isn't wanted.
         */
        if (handler->daemonize && !handler->conf->autodev) {
+               char path[PATH_MAX];
+               
+               ret = snprintf(path, sizeof(path), "%s/dev/null",
+                              handler->conf->rootfs.mount);
+               if (ret < 0 || ret >= sizeof(path))
+                       goto out_warn_father;
+               
                ret = access(path, F_OK);
                if (ret != 0) {
                        devnull_fd = open_devnull();
                ret = access(path, F_OK);
                if (ret != 0) {
                        devnull_fd = open_devnull();