From owner-freebsd-current Tue Feb 26 6:42: 0 2002 Delivered-To: freebsd-current@freebsd.org Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by hub.freebsd.org (Postfix) with ESMTP id 2E8B437B402 for ; Tue, 26 Feb 2002 06:41:54 -0800 (PST) Received: (from dufault@localhost) by hda.hda.com (8.11.6/8.11.6) id g1QEfZx00545; Tue, 26 Feb 2002 09:41:35 -0500 (EST) (envelope-from dufault) Date: Tue, 26 Feb 2002 09:41:34 -0500 From: Peter Dufault To: "M. Warner Losh" Cc: mike_makonnen@yahoo.com, peter@wemm.org, current@FreeBSD.ORG Subject: Re: HEADS UP: cvs commit: src/sys/conf kern.pre.mk (fwd) Message-ID: <20020226094134.A503@hda.hda.com> References: <20020226014624.8D6A03BAC@overcee.wemm.org> <20020225.215923.28857552.imp@village.org> <1014700670.677.9.camel@blackbox.pacbell.net> <20020225.233512.13036502.imp@village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020225.233512.13036502.imp@village.org>; from imp@village.org on Mon, Feb 25, 2002 at 11:35:12PM -0700 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 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. I don't think there is a GCC attribute to get around this differently. Peter PS - this is a quick example, please no one comment on the size of unsigned int or using gcc typeof instead, etc. -- Peter Dufault (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Fail-Safe systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message