Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-16980 build: fix gcc-12 [-Werror=format-truncation=] error
[fs/lustre-release.git]
/
lnet
/
utils
/
lnetconfig
/
liblnetconfig.c
diff --git
a/lnet/utils/lnetconfig/liblnetconfig.c
b/lnet/utils/lnetconfig/liblnetconfig.c
index
ff90496
..
15d9879
100644
(file)
--- a/
lnet/utils/lnetconfig/liblnetconfig.c
+++ b/
lnet/utils/lnetconfig/liblnetconfig.c
@@
-87,12
+87,12
@@
int open_sysfs_file(const char *path, const char *attr, const int mode)
{
int fd;
char filename[LNET_MAX_STR_LEN];
+ size_t size = sizeof(filename);
+ int namelen;
- if (strlen(path) + strlen(attr) >= LNET_MAX_STR_LEN)
- return -1;
-
- snprintf(filename, sizeof(filename), "%s%s",
- path, attr);
+ namelen = snprintf(filename, size, "%s%s", path, attr);
+ if (namelen >= size)
+ filename[size - 1] = '\0';
fd = open(filename, mode);