Whamcloud - gitweb
LU-16980 build: fix gcc-12 [-Werror=format-truncation=] error
authorJian Yu <yujian@whamcloud.com>
Mon, 31 Jul 2023 15:17:56 +0000 (08:17 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 1 Aug 2023 22:03:54 +0000 (22:03 +0000)
commitde37834f1ec61ea56c02d9065083c5b1af827c75
treebbae7e159a53f242dfbc86deb6c919ede6a8d453
parentfbcb200628981f0cf01114c2016d2ebfbe575b28
LU-16980 build: fix gcc-12 [-Werror=format-truncation=] error

This patch fixes the following [-Werror=format-truncation=] errors
detected by gcc 12:

liblnetconfig.c: In function 'open_sysfs_file':
liblnetconfig.c:106:49: error: '%s' directive output may be truncated
writing up to 127 bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
  106 |         snprintf(filename, sizeof(filename), "%s%s",
      |                                                 ^~

lfs_project.c: In function 'lfs_project_handle_dir':
lfs_project.c:324:50: error: '%s' directive output may be truncated
writing up to 255 bytes into a region of size between 1 and 4095
[-Werror=format-truncation=]
  324 |                 snprintf(fullname, PATH_MAX, "%s/%s", pathname,
      |                                                  ^~

statx.c: In function 'do_dir_list':
statx.c:1427:58: error: '%s' directive output may be truncated
writing up to 255 bytes into a region of size between 1 and 4095
[-Werror=format-truncation=]
 1427 |                         snprintf(fullname, PATH_MAX, "%s/%s",
      |                                                          ^~

Lustre-change: https://review.whamcloud.com/51765
Lustre-commit: TBD (from c976fe2f854e621dc16810ff8d0afafe4278bd14)

Change-Id: I514a1022d879f8b7af89f6ded68e9b453cd11408
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51774
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c
lustre/tests/statx.c
lustre/utils/lfs_project.c