git: af87ba65223f - main - traceroute: Silence compiler warning
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 03 Feb 2024 04:08:04 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=af87ba65223f05e14590a2564e8c7b4eec7b53a7 commit af87ba65223f05e14590a2564e8c7b4eec7b53a7 Author: Jose Luis Duran <jlduran@gmail.com> AuthorDate: 2023-11-17 16:15:27 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-03 03:14:09 +0000 traceroute: Silence compiler warning Silence the warning: argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination?" by using strlcpy() and the size of the destination (device). No functional change intended. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/901 --- contrib/traceroute/ifaddrlist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/traceroute/ifaddrlist.c b/contrib/traceroute/ifaddrlist.c index f9a72b28d4a7..0523a47ce61d 100644 --- a/contrib/traceroute/ifaddrlist.c +++ b/contrib/traceroute/ifaddrlist.c @@ -141,8 +141,7 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf) continue; - (void)strncpy(device, ifr.ifr_name, sizeof(ifr.ifr_name)); - device[sizeof(device) - 1] = '\0'; + (void)strlcpy(device, ifr.ifr_name, sizeof(device)); #ifdef sun /* Ignore sun virtual interfaces */ if (strchr(device, ':') != NULL)