Skip to content

Commit

Permalink
prov/lnx: fix av strncpy
Browse files Browse the repository at this point in the history
Fix compiler error with strncpy:

prov/lnx/src/lnx_av.c:272:4: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation]
    strncpy(peer_prov->lpp_prov_name, prov_name, FI_NAME_MAX);

Both dest and srouce are FI_NAME_MAX but strncpy is complaining that it doesn't have space for the NULL
terminator if it needs to be truncated. The terminator should already be in the prov_name passed in.
Just turn this into a memcpy to make the compiler happy

Signed-off-by: Alexia Ingerson <[email protected]>
  • Loading branch information
aingerson authored and j-xiong committed Nov 23, 2024
1 parent 8cf1e53 commit d4b7477
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion prov/lnx/src/lnx_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ static int lnx_get_or_create_peer_prov(struct dlist_entry *prov_table,
dlist_init(&peer_prov->entry);
dlist_init(&peer_prov->lpp_map);

strncpy(peer_prov->lpp_prov_name, prov_name, FI_NAME_MAX);
memcpy(peer_prov->lpp_prov_name, prov_name,
FI_NAME_MAX);

peer_prov->lpp_prov = entry;

Expand Down

0 comments on commit d4b7477

Please sign in to comment.