From owner-svn-src-all@FreeBSD.ORG Tue Aug 10 18:10:07 2010 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5CF61065673; Tue, 10 Aug 2010 18:10:07 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 46FA78FC14; Tue, 10 Aug 2010 18:10:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o7AI0VND076887; Tue, 10 Aug 2010 12:00:31 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 10 Aug 2010 12:01:03 -0600 (MDT) Message-Id: <20100810.120103.69891821625677670.imp@bsdimp.com> To: des@des.no From: "M. Warner Losh" In-Reply-To: <86sk2m1hsj.fsf@ds4.des.no> References: <201008101623.o7AGNs7I042679@haluter.fromme.com> <20100810.110642.335141733495090585.imp@bsdimp.com> <86sk2m1hsj.fsf@ds4.des.no> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: src-committers@FreeBSD.org, jilles@stack.nl, svn-src-all@FreeBSD.org, olli@fromme.com, olli@FreeBSD.org, svn-src-head@FreeBSD.org Subject: Re: svn commit: r211023 - head/usr.sbin/syslogd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2010 18:10:07 -0000 In message: <86sk2m1hsj.fsf@ds4.des.no> Dag-Erling Sm=F8rgrav writes: : "M. Warner Losh" writes: : > /* : > * Macros to cast a struct sockaddr, or parts thereof. : > * On architectures with strict alignment requirements, the compile= r : > * can bogusly warn about alignment problems since its static analy= sis : > * is insufficient for it to know that with the APIs used, there : > * really is no alignment issue. : > */ : = : That's a bit harsh on the compiler, don't you think? It never pays t= o : hurt the compiler's feelings :) /* * Macros to cast a struct sockaddr, or parts thereof. struct * sockaddr's alginment is loose to later be cast to a sockaddr_in or * sockaddr_in6. On architectures with strict alignment requirements, * this leads to compiler warnings because the compiler doesn't know * the ABI guarantees proper alignment. */ But this leads me to think that the right fix might be: /* * Structure used by kernel to store most * addresses. */ struct sockaddr { unsigned char sa_len; /* total length */ sa_family_t sa_family; /* address family */ char sa_data[14]; /* actually longer; address value */ } __aligned(4); since that's what the ABI defines.... : > : @@ -2410,8 +2419,8 @@ : > : } : > : reject =3D 0; : > : for (j =3D 0; j < 16; j +=3D 4) { : > : - if ((*(u_int32_t *)&sin6->sin6_addr.s6_addr[j] & *(u_int32_= t *)&m6p->sin6_addr.s6_addr[j]) : > : - !=3D *(u_int32_t *)&a6p->sin6_addr.s6_addr[j]) { : > : + if ((UINT32_CAST(sin6->sin6_addr.s6_addr[j]) & UINT32_CAST(= m6p->sin6_addr.s6_addr[j])) : > : + !=3D UINT32_CAST(a6p->sin6_addr.s6_addr[j])) { : > : ++reject; : > : break; : > : } : > : = : > : = : > : > Why 16 and 4 here? What's so magical about them? : = : 4 =3D bytes in a uint32_t, 16 =3D bytes in an ipv6 address. Isn't that better served by 'sizeof(uint32_t)' and 'sizeof(ipv6_addr_t)'? Warner