From owner-freebsd-current Tue Feb 26 15:36:47 2002 Delivered-To: freebsd-current@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 7499F37B41C for ; Tue, 26 Feb 2002 15:36:41 -0800 (PST) Received: from peter3.wemm.org ([12.232.27.13]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020226233641.VFON1147.rwcrmhc52.attbi.com@peter3.wemm.org> for ; Tue, 26 Feb 2002 23:36:41 +0000 Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by peter3.wemm.org (8.11.0/8.11.0) with ESMTP id g1QNaes69855 for ; Tue, 26 Feb 2002 15:36:40 -0800 (PST) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (Postfix) with ESMTP id BEDA93BB0; Tue, 26 Feb 2002 15:36:40 -0800 (PST) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Peter Dufault Cc: "M. Warner Losh" , mike_makonnen@yahoo.com, current@FreeBSD.ORG Subject: Re: HEADS UP: cvs commit: src/sys/conf kern.pre.mk (fwd) In-Reply-To: <20020226094134.A503@hda.hda.com> Date: Tue, 26 Feb 2002 15:36:40 -0800 From: Peter Wemm Message-Id: <20020226233640.BEDA93BB0@overcee.wemm.org> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Peter Dufault wrote: > On Mon, Feb 25, 2002 at 11:35:12PM -0700, M. Warner Losh wrote: > > In message: <1014700670.677.9.camel@blackbox.pacbell.net> > > Mike Makonnen writes: > > : On Mon, 2002-02-25 at 20:59, M. Warner Losh wrote: > > : > I've fixed a few of the low hanging fruit, but I don't know how to get > > : > rid of warnings like: > > : > > > : > const char *foo = "blah"; > > : > char *baz = foo; > > : > > > : > when I know they are safe. > > : > > : Correct me if I'm wrong, but isn't the correct declaration: > > : > > : const char foo[] = "blah"; > > : char baz[] = "foo"; > > > > You miss the point. First, there's no "" around foo. Second, what I > > quoted was boiled down from a bunch of macros and such. Third, the > > real example would be > > > > volatile int conspeed; > > int *foo = &conspeed; > > > > Where foo is only accessed before all other accesses to conspeed. > > When it is too twisty to fix at the moment I use macros such as: > > #define BOGUSLY_CAST_AWAY_VOLATILITY(T,P) ((T)(unsigned int)(P)) > > ... > > volatile int conspeed; int *foo = > BOGUSLY_CAST_AWAY_VOLATILITY(int *, &conspeed); > > to surpress the warnings. You can easily redefine the macro to get > them back so together with the discouraging name you're not sweeping > things under the rug. In sys/cdefs.h, we have: #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) .. but bde threatened bodily harm for using it if I recall correctly. There is also __DEVOLATILE() and __DEQUALIFY() Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message