From: Christian Brauner Date: Sun, 18 Feb 2018 22:46:37 +0000 (+0100) Subject: start: lxc_check_inherited() X-Git-Tag: lxc-2.0.10~259 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7070388108c3d5db14a7083c6a34a2188cd5be8b;p=thirdparty%2Flxc.git start: lxc_check_inherited() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/start.c b/src/lxc/start.c index 0a9dc3a6b..c77594674 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -192,10 +192,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; @@ -203,21 +203,24 @@ 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))) { - if (!strcmp(direntp->d_name, ".")) + int ret; + + 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; }