From 01a95d942eda62e8b223c1746b03a25496590fcc Mon Sep 17 00:00:00 2001 From: John Hay <jhay@FreeBSD.org> Date: Sat, 13 Apr 1996 14:37:22 +0000 Subject: [PATCH] Don't use a newfangled auto initializer. Initialize everything by assignment to avoid one bug and several pessimizations. In the old version, gcc-2.6.3 (i386 version) generates 16 bytes of static data and copies it using 4 4-byte load-stores. gcc-2.7.2 generates 2 1-byte stores and calls memset() to zero 14 bytes. Linking fails because memset() doesn't exist in the kernel. In both versions, the 2 bytes stored directly are all that is actually used unless the null padding at the end is used, since the 3 4-byte words in the middle are initialized again by struct assignment. These words are misaligned. gcc generates misaligned load-stores for (small) misaligned struct copies. Submitted by: Bruce Evans --- sys/netipx/ipx_usrreq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c index 5fe86aa90cb2..6a0fc4a70c9a 100644 --- a/sys/netipx/ipx_usrreq.c +++ b/sys/netipx/ipx_usrreq.c @@ -33,7 +33,7 @@ * * @(#)ipx_usrreq.c * - * $Id: ipx_usrreq.c,v 1.4 1995/11/04 09:03:24 julian Exp $ + * $Id: ipx_usrreq.c,v 1.5 1996/03/11 15:13:57 davidg Exp $ */ #include <sys/param.h> @@ -75,7 +75,7 @@ ipx_input(m, ipxp) { register struct ipx *ipx = mtod(m, struct ipx *); struct ifnet *ifp = m->m_pkthdr.rcvif; - struct sockaddr_ipx ipx_ipx = { sizeof(ipx_ipx), AF_IPX }; + struct sockaddr_ipx ipx_ipx; if (ipxp==0) panic("No ipxpcb"); @@ -83,7 +83,11 @@ ipx_input(m, ipxp) * Construct sockaddr format source address. * Stuff source address and datagram in user buffer. */ + ipx_ipx.sipx_len = sizeof(ipx_ipx); + ipx_ipx.sipx_family = AF_IPX; ipx_ipx.sipx_addr = ipx->ipx_sna; + ipx_ipx.sipx_zero[0] = '\0'; + ipx_ipx.sipx_zero[1] = '\0'; if (ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet) && ifp) { register struct ifaddr *ifa;