From nobody Thu Jan 27 00:36:23 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E24B2197AE1B; Thu, 27 Jan 2022 00:36:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JkhTz5q0Yz4m5R; Thu, 27 Jan 2022 00:36:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643243783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oPneYSQLU6Ho/xODbKwZILBZHNRjoRBC8h/77SCjzJw=; b=FQqs7kKPN2/ARRY7rAyN9RpOssKQOtGRbMU66ri+Bk9KWyXP88IuOosSFPTDHTPM6XN+u2 G8bzRiPq8YXz/I4OiNzmXDy6gKR9DwFaqNg9R+6RzQdKD6WVZ342tbUcaTY3qmA0B9H9eX ikPniW9jS6HLlIvEGksvaBXM58uAty35rNAycJjL2oYfT5oLPZH9N7IqWRr7emGVlTiyON 74msJWj6qmO/STVG+u925kBblOmBYIGSA7JgCkXRIKyCKmQTlsQJGkpD7WfNk6j6flb8UP G4mAYFHpgU6QHTdNggwyIgWKAuRf+Hzkk9N/xhYmNxrU5x8MKsoBElCfcXwSiQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A383C4D91; Thu, 27 Jan 2022 00:36:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20R0aNX1029212; Thu, 27 Jan 2022 00:36:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20R0aN8L029211; Thu, 27 Jan 2022 00:36:23 GMT (envelope-from git) Date: Thu, 27 Jan 2022 00:36:23 GMT Message-Id: <202201270036.20R0aN8L029211@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: e5bcc6a85677 - stable/13 - route: remove write-only struct hostent from getaddr() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e5bcc6a85677bda49d0b88dfd4528b215d7009a5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643243783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oPneYSQLU6Ho/xODbKwZILBZHNRjoRBC8h/77SCjzJw=; b=uJmyYMYVjWH14BgHH8bT41mPIlSUpIoimbYkJRLucjr0cWOnpkeeZNpCqIibroqZGTIKUU I8IGn6sSGB2zsR8TvhbPD8s8MhLCOiAjtZC1Ylmo3c9LS1vaNF04JTZltaMcdpU8Ip7aYK +tKCQd19fo2dpT2SrbMTn87eNYqV0PAdyyuA+FG7FdlvdqlX2VglVVFEh48iWCxu0l65Ni cBbS/Y2iLnhHyhL96hqsDCAB//f657PBeT191MZytJXlPGGSLN17UUnZ/ZZdIiDqizWy7U oH+vTZBrOhsPETbq7n5+2q+Jd1pwk7oIOuoXaKIlgynmmMDA9+Aak4Um2JgyYw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643243783; a=rsa-sha256; cv=none; b=bdRhYf3aykvQ+3rFufXDqY9utUNDHS2BuSomVGu6Q2j6QKF/9ImXKbc5MGhgRpZGGL7Ne7 8PGvL5v+DzK987U8mF6qQD/wOvlTAYBLCsgSjBk50+XJ8RLVKSPZBI1fNk9lg3caoEC+/c B2EJ4xJ+EavcJr7Wq2yieWqfhUCEB6T4Xw5XWs3+3jbb70ehXDEHvrCxe3v/lHUW7nzOFO T2RXoIsOSfLny4nCxD8rmmaONq/AnXA/H4svgtL4Aks2VmfKt+aKaljsUWlgvjG8C/5jHl ejbr18axOsnEnMHus1pNHgRHr8F1xkULjVcsPIBdxrKnz5DOIetmokmpKDxQgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e5bcc6a85677bda49d0b88dfd4528b215d7009a5 commit e5bcc6a85677bda49d0b88dfd4528b215d7009a5 Author: Ed Maste AuthorDate: 2021-12-31 18:21:13 +0000 Commit: Ed Maste 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)));