Whamcloud - gitweb
LU-14093 utils: trivial changes to support gcc10
[fs/lustre-release.git] / lustre / utils / lfs_project.c
index d8b1500..8471c6d 100644 (file)
 #include "lfs_project.h"
 #include <lustre/lustreapi.h>
 
 #include "lfs_project.h"
 #include <lustre/lustreapi.h>
 
+const char     *progname;
+
 struct lfs_project_item {
        struct list_head lpi_list;
 struct lfs_project_item {
        struct list_head lpi_list;
-       char lpi_pathname[PATH_MAX];
+       char *lpi_pathname;
 };
 
 static int
 };
 
 static int
@@ -69,8 +71,12 @@ lfs_project_item_alloc(struct list_head *head, const char *pathname)
                return -ENOMEM;
        }
 
                return -ENOMEM;
        }
 
-       strncpy(lpi->lpi_pathname, pathname, sizeof(lpi->lpi_pathname) - 1);
-       list_add_tail(&lpi->lpi_list, head);
+       lpi->lpi_pathname = strdup(pathname);
+       if (!lpi->lpi_pathname) {
+               free(lpi);
+               return -ENOMEM;
+       } else
+               list_add_tail(&lpi->lpi_list, head);
 
        return 0;
 }
 
        return 0;
 }
@@ -334,6 +340,7 @@ static int lfs_project_iterate(const char *pathname,
                                             phc, func);
                if (!ret && rc)
                        ret = rc;
                                             phc, func);
                if (!ret && rc)
                        ret = rc;
+               free(lpi->lpi_pathname);
                free(lpi);
        }
 
                free(lpi);
        }