From owner-svn-src-head@freebsd.org Tue Mar 27 20:51:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D89A0F5A77E; Tue, 27 Mar 2018 20:51:50 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8608B800B7; Tue, 27 Mar 2018 20:51:50 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 811AD21390; Tue, 27 Mar 2018 20:51:50 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2RKporl064730; Tue, 27 Mar 2018 20:51:50 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2RKpnYT064723; Tue, 27 Mar 2018 20:51:49 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201803272051.w2RKpnYT064723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Tue, 27 Mar 2018 20:51:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331648 - in head/sys: net ofed/drivers/infiniband/ulp/ipoib X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/sys: net ofed/drivers/infiniband/ulp/ipoib X-SVN-Commit-Revision: 331648 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Mar 2018 20:51:51 -0000 Author: brooks Date: Tue Mar 27 20:51:49 2018 New Revision: 331648 URL: https://svnweb.freebsd.org/changeset/base/331648 Log: Improve copy-and-pasted versions of SIOCGIFADDR. The original implementation used a reference to ifr_data and a cast to do the equivalent of accessing ifr_addr. This was copied multiple times since 1996. Approved by: kib MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14873 Modified: head/sys/net/if_arcsubr.c head/sys/net/if_ethersubr.c head/sys/net/if_fddisubr.c head/sys/net/if_fwsubr.c head/sys/net/if_iso88025subr.c head/sys/net/if_vlan.c head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Modified: head/sys/net/if_arcsubr.c ============================================================================== --- head/sys/net/if_arcsubr.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/net/if_arcsubr.c Tue Mar 27 20:51:49 2018 (r331648) @@ -681,12 +681,7 @@ arc_ioctl(struct ifnet *ifp, u_long command, caddr_t d break; case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *) &ifr->ifr_data; - *(u_int8_t *)sa->sa_data = ARC_LLADDR(ifp); - } + ifr->ifr_addr.sa_data[0] = ARC_LLADDR(ifp); break; case SIOCADDMULTI: Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/net/if_ethersubr.c Tue Mar 27 20:51:49 2018 (r331648) @@ -1108,13 +1108,8 @@ ether_ioctl(struct ifnet *ifp, u_long command, caddr_t break; case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy(IF_LLADDR(ifp), - (caddr_t) sa->sa_data, ETHER_ADDR_LEN); - } + bcopy(IF_LLADDR(ifp), &ifr->ifr_addr.sa_data[0], + ETHER_ADDR_LEN); break; case SIOCSIFMTU: Modified: head/sys/net/if_fddisubr.c ============================================================================== --- head/sys/net/if_fddisubr.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/net/if_fddisubr.c Tue Mar 27 20:51:49 2018 (r331648) @@ -558,14 +558,9 @@ fddi_ioctl (ifp, command, data) break; } break; - case SIOCGIFADDR: { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy(IF_LLADDR(ifp), - (caddr_t) sa->sa_data, FDDI_ADDR_LEN); - - } + case SIOCGIFADDR: + bcopy(IF_LLADDR(ifp), &ifr->ifr_addr.sa_data[0], + FDDI_ADDR_LEN); break; case SIOCSIFMTU: /* Modified: head/sys/net/if_fwsubr.c ============================================================================== --- head/sys/net/if_fwsubr.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/net/if_fwsubr.c Tue Mar 27 20:51:49 2018 (r331648) @@ -662,13 +662,8 @@ firewire_ioctl(struct ifnet *ifp, u_long command, cadd break; case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy(&IFP2FWC(ifp)->fc_hwaddr, - (caddr_t) sa->sa_data, sizeof(struct fw_hwaddr)); - } + bcopy(&IFP2FWC(ifp)->fc_hwaddr, &ifr->ifr_addr.sa_data[0], + sizeof(struct fw_hwaddr)); break; case SIOCSIFMTU: Modified: head/sys/net/if_iso88025subr.c ============================================================================== --- head/sys/net/if_iso88025subr.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/net/if_iso88025subr.c Tue Mar 27 20:51:49 2018 (r331648) @@ -173,13 +173,9 @@ iso88025_ioctl(struct ifnet *ifp, u_long command, cadd } break; - case SIOCGIFADDR: { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy(IF_LLADDR(ifp), - (caddr_t) sa->sa_data, ISO88025_ADDR_LEN); - } + case SIOCGIFADDR: + bcopy(IF_LLADDR(ifp), &ifr->ifr_addr.sa_data[0], + ISO88025_ADDR_LEN); break; case SIOCSIFMTU: Modified: head/sys/net/if_vlan.c ============================================================================== --- head/sys/net/if_vlan.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/net/if_vlan.c Tue Mar 27 20:51:49 2018 (r331648) @@ -1790,12 +1790,8 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data #endif break; case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *)&ifr->ifr_data; - bcopy(IF_LLADDR(ifp), sa->sa_data, ifp->if_addrlen); - } + bcopy(IF_LLADDR(ifp), &ifr->ifr_addr.sa_data[0], + ifp->if_addrlen); break; case SIOCGIFMEDIA: VLAN_SLOCK(); Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c ============================================================================== --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Tue Mar 27 20:49:47 2018 (r331647) +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Tue Mar 27 20:51:49 2018 (r331648) @@ -320,13 +320,8 @@ ipoib_ioctl(struct ifnet *ifp, u_long command, caddr_t break; case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy(IF_LLADDR(ifp), - (caddr_t) sa->sa_data, INFINIBAND_ALEN); - } + bcopy(IF_LLADDR(ifp), &ifr->ifr_addr.sa_data[0], + INFINIBAND_ALEN); break; case SIOCSIFMTU: