From owner-cvs-src@FreeBSD.ORG Wed Dec 5 04:35:39 2007 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8810116A421; Wed, 5 Dec 2007 04:35:39 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail13.syd.optusnet.com.au (mail13.syd.optusnet.com.au [211.29.132.194]) by mx1.freebsd.org (Postfix) with ESMTP id 0D40013C448; Wed, 5 Dec 2007 04:35:38 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c211-30-219-213.carlnfd3.nsw.optusnet.com.au (c211-30-219-213.carlnfd3.nsw.optusnet.com.au [211.30.219.213]) by mail13.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id lB54ZOMQ031783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Dec 2007 15:35:27 +1100 Date: Wed, 5 Dec 2007 15:35:24 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Max Laier In-Reply-To: <200712041928.36391.max@love2party.net> Message-ID: <20071205151552.T7146@delplex.bde.org> References: <200711232356.lANNu3mp040885@repoman.freebsd.org> <200712031657.34074.jhb@freebsd.org> <20071204172535.GB82261@FreeBSD.org> <200712041928.36391.max@love2party.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Alexey Dokuchaev , src-committers@freebsd.org, John Baldwin , cvs-src@freebsd.org, cvs-all@freebsd.org, John Birrell , Dag-Erling Sm??rgrav Subject: Re: cvs commit: src/sys/netinet/libalias alias_util.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Dec 2007 04:35:39 -0000 On Tue, 4 Dec 2007, Max Laier wrote: > On Tuesday 04 December 2007, Alexey Dokuchaev wrote: >> On Mon, Dec 03, 2007 at 04:57:33PM -0500, John Baldwin wrote: >>> On Monday 03 December 2007 10:24:52 am Dag-Erling Sm??rgrav wrote: >>>> John Birrell writes: >>>>> Log: >>>>> Fix strict alias warnings. >>>> >>>> A much simpler solution (relative to the previous revision): >>>> >>>> @@ -131,10 +131,10 @@ >>>> sum += oddbyte; >>>> } >>>> /* "Pseudo-header" data */ >>>> - ptr = (u_short *) & (pip->ip_dst); >>>> + ptr = (void *)&pip->ip_dst; >>>> sum += *ptr++; >>>> sum += *ptr; >>>> - ptr = (u_short *) & (pip->ip_src); >>>> + ptr = (void *)&pip->ip_src; >>>> sum += *ptr++; >>>> sum += *ptr; >>>> sum += htons((u_short) ntcp); >>> >>> *ptr++ would choke since pointer arith on (void *) is undefined >>> AFAIK. Um, ptr has type `u_short *', not `void *'. The original cast was used to break a warning (and to add 3 style bugs). With stricter type checking, it stopped "working". Now the warning is broken by casting to `void *' which removes all knowledge of alignment restrictions and I suppose must relax aliasing rules (else `void *' couldn't be used for anything). >> I've been under impression that ++ on void * whould simply increase it >> by one. This is a gcc bugfeature. It is disabled by -Wpointer-arith for FreeBSD kernels. > wasn't that the reason why caddr_t exists? i.e. pointer arithmetic on > void * is bad, but on caddr_t it's kinda okay. caddr_t is just an old mistake in this area. The kernel still hasn't caught up with the post K&R-1 (1978) changes which introduced `void *'. (A few places might need to represent "core" addresses that can't be represented by `void *' due to separate address spaces or things like PAE, but that problem is now handed by vm_^Woffset_t, vm_paddr_t and vm_ooffset_t. caddr_t = `char *' has never been able to handle it. "core" mostly means "mapped", so the problem doesn't affect most uses of caddr_t.) Bruce