Whamcloud - gitweb
LU-11899 utils: Possible resource/memory leaks
[fs/lustre-release.git] / lustre / utils / lfs_project.c
index a2e9eb2..d61b038 100644 (file)
@@ -90,6 +90,7 @@ static int project_get_xattr(const char *pathname, struct fsxattr *fsx)
        if (ret) {
                fprintf(stderr, "%s: failed to get xattr for '%s': %s\n",
                        progname, pathname, strerror(errno));
+               close(fd);
                return -errno;
        }
        return fd;
@@ -261,10 +262,6 @@ lfs_project_handle_dir(struct list_head *head, const char *pathname,
                }
        }
 
-       if (ret)
-               fprintf(stderr, "%s: failed to handle dir '%s': %s\n",
-                       progname, pathname, strerror(errno));
-
        closedir(dir);
        return ret;
 }
@@ -304,12 +301,10 @@ static int lfs_project_iterate(const char *pathname,
        while (!list_empty(&head)) {
                lpi = list_entry(head.next, struct lfs_project_item, lpi_list);
                list_del(&lpi->lpi_list);
-               if (rc == 0) {
-                       rc = lfs_project_handle_dir(&head, lpi->lpi_pathname,
-                                                    phc, func);
-                       if (!ret && rc)
-                               ret = rc;
-               }
+               rc = lfs_project_handle_dir(&head, lpi->lpi_pathname,
+                                            phc, func);
+               if (!ret && rc)
+                       ret = rc;
                free(lpi);
        }