Whamcloud - gitweb
LU-16980 build: fix gcc-12 [-Werror=format-truncation=] error 65/51765/3
authorJian Yu <yujian@whamcloud.com>
Mon, 31 Jul 2023 09:03:46 +0000 (02:03 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 7 Aug 2023 03:50:34 +0000 (03:50 +0000)
commit347cf32326a5be282e311f140cdc850bde46176b
tree9b807c19078e5237037f3e821160388eb5daaed4
parent8d4f9d1befb9962335d4cbc5b89cafced286b066
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",
      |                                                          ^~

Change-Id: I514a1022d879f8b7af89f6ded68e9b453cd11408
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51765
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c
lustre/tests/statx.c
lustre/utils/lfs_project.c