git: e5bcc6a85677 - stable/13 - route: remove write-only struct hostent from getaddr()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Jan 2022 00:36:23 UTC
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e5bcc6a85677bda49d0b88dfd4528b215d7009a5 commit e5bcc6a85677bda49d0b88dfd4528b215d7009a5 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-12-31 18:21:13 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-01-27 00:35:40 +0000 route: remove write-only struct hostent from getaddr() Under some INET/INET6 src.conf configurations sbin/route previously failed to build due to an unused variable warning. It was functionally write-only anyway, so just remove it. Reported by: melifaro Reviewed by: melifaro MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33717 (cherry picked from commit c2173903598a33122a8006a944158b95dd5e2d80) (cherry picked from commit f567fcb2ffc4180319e644796d6dbc51b51a4e04) --- sbin/route/route.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/sbin/route/route.c b/sbin/route/route.c index b16fb6d17a08..5f33cecb1b20 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -117,7 +117,7 @@ static TAILQ_HEAD(fibl_head_t, fibl) fibl_head; static void printb(int, const char *); static void flushroutes(int argc, char *argv[]); static int flushroutes_fib(int); -static int getaddr(int, char *, struct hostent **, int); +static int getaddr(int, char *, int); static int keyword(const char *); #ifdef INET static void inet_makemask(struct sockaddr_in *, u_long); @@ -790,7 +790,6 @@ static void newroute(int argc, char **argv) { struct sigaction sa; - struct hostent *hp; struct fibl *fl; char *cmd; const char *dest, *gateway, *errmsg; @@ -802,7 +801,6 @@ newroute(int argc, char **argv) gateway = NULL; flags = RTF_STATIC; nrflags = 0; - hp = NULL; TAILQ_INIT(&fibl_head); sigemptyset(&sa.sa_mask); @@ -893,35 +891,35 @@ newroute(int argc, char **argv) case K_IFA: if (!--argc) usage(NULL); - getaddr(RTAX_IFA, *++argv, 0, nrflags); + getaddr(RTAX_IFA, *++argv, nrflags); break; case K_IFP: if (!--argc) usage(NULL); - getaddr(RTAX_IFP, *++argv, 0, nrflags); + getaddr(RTAX_IFP, *++argv, nrflags); break; case K_GENMASK: if (!--argc) usage(NULL); - getaddr(RTAX_GENMASK, *++argv, 0, nrflags); + getaddr(RTAX_GENMASK, *++argv, nrflags); break; case K_GATEWAY: if (!--argc) usage(NULL); - getaddr(RTAX_GATEWAY, *++argv, 0, nrflags); + getaddr(RTAX_GATEWAY, *++argv, nrflags); gateway = *argv; break; case K_DST: if (!--argc) usage(NULL); - if (getaddr(RTAX_DST, *++argv, &hp, nrflags)) + if (getaddr(RTAX_DST, *++argv, nrflags)) nrflags |= F_ISHOST; dest = *argv; break; case K_NETMASK: if (!--argc) usage(NULL); - getaddr(RTAX_NETMASK, *++argv, 0, nrflags); + getaddr(RTAX_NETMASK, *++argv, nrflags); /* FALLTHROUGH */ case K_NET: nrflags |= F_FORCENET; @@ -956,13 +954,13 @@ newroute(int argc, char **argv) } else { if ((rtm_addrs & RTA_DST) == 0) { dest = *argv; - if (getaddr(RTAX_DST, *argv, &hp, nrflags)) + if (getaddr(RTAX_DST, *argv, nrflags)) nrflags |= F_ISHOST; } else if ((rtm_addrs & RTA_GATEWAY) == 0) { gateway = *argv; - getaddr(RTAX_GATEWAY, *argv, &hp, nrflags); + getaddr(RTAX_GATEWAY, *argv, nrflags); } else { - getaddr(RTAX_NETMASK, *argv, 0, nrflags); + getaddr(RTAX_NETMASK, *argv, nrflags); nrflags |= F_FORCENET; } } @@ -1154,7 +1152,7 @@ inet6_makenetandmask(struct sockaddr_in6 *sin6, const char *plen) * returning 1 if a host address, 0 if a network address. */ static int -getaddr(int idx, char *str, struct hostent **hpp, int nrflags) +getaddr(int idx, char *str, int nrflags) { struct sockaddr *sa; #if defined(INET) @@ -1179,9 +1177,6 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags) aflen = sizeof(struct sockaddr_dl); #endif } -#ifndef INET - hpp = NULL; -#endif rtm_addrs |= (1 << idx); sa = (struct sockaddr *)&so[idx]; sa->sa_family = af; @@ -1233,7 +1228,7 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags) switch (idx) { case RTAX_DST: nrflags |= F_FORCENET; - getaddr(RTAX_NETMASK, str, 0, nrflags); + getaddr(RTAX_NETMASK, str, nrflags); break; } return (0); @@ -1280,9 +1275,6 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags) #ifdef INET sin = (struct sockaddr_in *)(void *)sa; - if (hpp == NULL) - hpp = &hp; - *hpp = NULL; q = strchr(str,'/'); if (q != NULL && idx == RTAX_DST) { @@ -1303,7 +1295,6 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags) hp = gethostbyname(str); if (hp != NULL) { - *hpp = hp; sin->sin_family = hp->h_addrtype; memmove((char *)&sin->sin_addr, hp->h_addr, MIN((size_t)hp->h_length, sizeof(sin->sin_addr)));