From owner-svn-src-all@FreeBSD.ORG Tue Oct 15 13:41:26 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6A456712; Tue, 15 Oct 2013 13:41:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by mx1.freebsd.org (Postfix) with ESMTP id 1B80624B0; Tue, 15 Oct 2013 13:41:25 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id 55F36781427; Wed, 16 Oct 2013 00:41:14 +1100 (EST) Date: Wed, 16 Oct 2013 00:41:13 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Kevin Lo Subject: Re: svn commit: r256505 - head/sys/netinet In-Reply-To: <201310150735.r9F7ZdIt094705@svn.freebsd.org> Message-ID: <20131015231355.H1194@besplex.bde.org> References: <201310150735.r9F7ZdIt094705@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=DstvpgP+ c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=OruT19piMXgA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=dTaYT270HIcA:10 a=SUtqVvnYs5MZ5z3BSsYA:9 a=IyTK3-r1_Kbg-V_c:21 a=9S8xqpn5IB7KL5v-:21 a=CjuIK1q_8ugA:10 Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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, 15 Oct 2013 13:41:26 -0000 On Tue, 15 Oct 2013, Kevin Lo wrote: > Log: > Treat INADDR_NONE as uint32_t. > > Reviewed by: glebius > Modified: > head/sys/netinet/in.h > > Modified: head/sys/netinet/in.h > ============================================================================== > --- head/sys/netinet/in.h Tue Oct 15 06:38:40 2013 (r256504) > +++ head/sys/netinet/in.h Tue Oct 15 07:35:39 2013 (r256505) > @@ -379,7 +379,7 @@ __END_DECLS > > #define INADDR_LOOPBACK (u_int32_t)0x7f000001 The old casts of inet address macros are remarkably buggy: - all are missing parentheses. This gives an incorrect parse for weird code like INADDR_LOOPBACK[array] (this syntax is valid but gives different semantics to array[INADDR_LOOPBACK], unlike if the array and the index are either correctly written macros or not macros. - all cast to u_int32_t instead of to in_addr_t. This is not just a style bug. u_int32_t isn't even declared, except accidentally via namespace pollution. > #ifndef _KERNEL > -#define INADDR_NONE 0xffffffff /* -1 return */ > +#define INADDR_NONE (uint32_t)0xffffffff /* -1 return */ This cast has no effect (except to add bugs) on any supported arch, since all supported arches have 32-bit ints. I first thought that this copied all the bugs from one of the old casts. Actually, it uses a not-incorrect type, so its bugs are only: - missing parentheses - the type is not visually identical to the type of an inet address (in_addr_t) - it is a style bug to not be bug for bug compatible with the spelling in the old casts. > #endif > > #define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ > u_int32_t is also used in many non-address macros starting with IN_CLASSA(). These macros don't aren't missing parentheses. I thought that namespace errors in had all been fixed. It carefully declares in_addr_t and uint32_t, but still uses u_int32_t in the POSIX inet address macros; these macros are also placed before the typedefs. Bruce