From 9b0b7264a8d7a6a2abe681d15fefc88c27d20c1e Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Thu, 9 Dec 2021 12:00:36 -0800 Subject: [PATCH] LU-15220 utils: fix gcc-11 -Werror=format-truncation= error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch fixes the following -Werror=format-truncation= error in liblustreapi.c: liblustreapi.c: In function ‘lov_dump_comp_v1’: liblustreapi.c:3673:57: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 3673 | snprintf(pool_name, LOV_MAXPOOLNAME, "%s", | ^ Change-Id: I55c3e05a933ff3d2c33a71ed269fffe63797b528 Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/45815 Reviewed-by: James Simmons Tested-by: jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Sergey Cheremencev Reviewed-by: Oleg Drokin --- lustre/utils/liblustreapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index b55e51c..ca5debe 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -3670,7 +3670,7 @@ static inline void lov_v1v3_pool_name(struct lov_user_md *v1, char *pool_name) { if (v1->lmm_magic == LOV_USER_MAGIC_V3) - snprintf(pool_name, LOV_MAXPOOLNAME, "%s", + snprintf(pool_name, LOV_MAXPOOLNAME + 1, "%s", ((struct lov_user_md_v3 *)v1)->lmm_pool_name); else pool_name[0] = '\0'; -- 1.8.3.1