]> git.proxmox.com Git - mirror_lxc.git/commitdiff
start: lxc_check_inherited()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 18 Feb 2018 22:46:37 +0000 (23:46 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 18 Feb 2018 22:46:37 +0000 (23:46 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index b99f2e584ceeed75bb7b5c45f39f57a6a2c382cb..413f75e0dea87342a92f6286ae16f1b7673003e3 100644 (file)
@@ -185,10 +185,10 @@ static int match_fd(int fd)
 int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
                        int *fds_to_ignore, size_t len_fds)
 {
-       struct dirent *direntp;
        int fd, fddir;
        size_t i;
        DIR *dir;
+       struct dirent *direntp;
 
        if (conf && conf->close_all_fds)
                closeall = true;
@@ -196,24 +196,26 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
 restart:
        dir = opendir("/proc/self/fd");
        if (!dir) {
-               WARN("Failed to open directory: %s.", strerror(errno));
+               WARN("%s - Failed to open directory", strerror(errno));
                return -1;
        }
 
        fddir = dirfd(dir);
 
        while ((direntp = readdir(dir))) {
+               int ret;
                struct lxc_list *cur;
                bool matched = false;
 
-               if (!strcmp(direntp->d_name, "."))
+               if (strcmp(direntp->d_name, ".") == 0)
                        continue;
 
-               if (!strcmp(direntp->d_name, ".."))
+               if (strcmp(direntp->d_name, "..") == 0)
                        continue;
 
-               if (lxc_safe_int(direntp->d_name, &fd) < 0) {
-                       INFO("Could not parse file descriptor for: %s", direntp->d_name);
+               ret = lxc_safe_int(direntp->d_name, &fd);
+               if (ret < 0) {
+                       INFO("Could not parse file descriptor for \"%s\"", direntp->d_name);
                        continue;
                }