Date: Tue, 27 Mar 2018 20:51:49 +0000 (UTC) From: Brooks Davis <brooks@FreeBSD.org> 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 Message-ID: <201803272051.w2RKpnYT064723@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803272051.w2RKpnYT064723>