Skip to content

Commit 502dd95

Browse files
committed
prov/verbs: Fix compiler warning on the bound of 'strncpy' call
Gcc 15 complains that the length parameter for strncpy() is derived from the source string. It is not a real concern since the result is guaranteed to be less than the buffer size due to the MIN operation. However, the calculation is slightly off anyway. So rewite the logic to kill two birds with one stone. Signed-off-by: Jianxin Xiong <[email protected]>
1 parent 8f506de commit 502dd95

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

prov/verbs/src/verbs_init.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,9 @@ static int vrb_param_define(const char *param_name, const char *param_str,
374374
switch (type) {
375375
case FI_PARAM_STRING:
376376
if (*(char **)param_default != NULL) {
377-
param_default_sz =
378-
MIN(strlen(*(char **)param_default),
379-
254);
380-
strncpy(param_default_str, *(char **)param_default,
381-
param_default_sz);
382-
param_default_str[param_default_sz + 1] = '\0';
377+
strncpy(param_default_str, *(char **)param_default, 255);
378+
param_default_str[255] = '\0';
379+
param_default_sz = strlen(param_default_str);
383380
}
384381
break;
385382
case FI_PARAM_INT:

0 commit comments

Comments
 (0)