From 79acd674e3bc49ac630d84ef64df2291fc9ade01 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Fri, 30 Oct 2020 09:48:27 +0300 Subject: [PATCH] LU-14093 utils: trivial changes to support gcc10 just to fix gcc10 complains. Signed-off-by: Alex Zhuravlev Change-Id: I8390d28fe78c9dad15a41301cc2b6d6184fdc330 Reviewed-on: https://review.whamcloud.com/40485 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo --- lustre/utils/lfs_project.c | 13 ++++++++++--- lustre/utils/lfs_project.h | 2 +- lustre/utils/mkfs_lustre.c | 2 +- lustre/utils/mount_utils.h | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lustre/utils/lfs_project.c b/lustre/utils/lfs_project.c index d8b15004..8471c6d 100644 --- a/lustre/utils/lfs_project.c +++ b/lustre/utils/lfs_project.c @@ -51,9 +51,11 @@ #include "lfs_project.h" #include +const char *progname; + struct lfs_project_item { struct list_head lpi_list; - char lpi_pathname[PATH_MAX]; + char *lpi_pathname; }; static int @@ -69,8 +71,12 @@ lfs_project_item_alloc(struct list_head *head, const char *pathname) 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; } @@ -334,6 +340,7 @@ static int lfs_project_iterate(const char *pathname, phc, func); if (!ret && rc) ret = rc; + free(lpi->lpi_pathname); free(lpi); } diff --git a/lustre/utils/lfs_project.h b/lustre/utils/lfs_project.h index 66404ca..01310a9 100644 --- a/lustre/utils/lfs_project.h +++ b/lustre/utils/lfs_project.h @@ -36,7 +36,7 @@ #include #include -const char *progname; +extern const char *progname; enum lfs_project_ops_t { LFS_PROJECT_CHECK = 0, diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 153a466..75979b9 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -271,7 +271,7 @@ static inline void badopt(const char *opt, char *type) static int erase_param(const char *const buf, const char *const param, bool withval) { - char search[PARAM_MAX + 1] = ""; + char search[PARAM_MAX + 8] = ""; char *buffer = (char *)buf; bool found = false; diff --git a/lustre/utils/mount_utils.h b/lustre/utils/mount_utils.h index b473e01..d7e4f6e 100644 --- a/lustre/utils/mount_utils.h +++ b/lustre/utils/mount_utils.h @@ -250,8 +250,8 @@ struct module_backfs_ops { void *dl_handle; }; -struct module_backfs_ops zfs_ops; -struct module_backfs_ops ldiskfs_ops; +extern struct module_backfs_ops zfs_ops; +extern struct module_backfs_ops ldiskfs_ops; struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type); void unload_backfs_ops(struct module_backfs_ops *ops); -- 1.8.3.1