From owner-freebsd-current Wed Feb 27 0:15:29 2002 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 19D4A37B400 for ; Wed, 27 Feb 2002 00:15:26 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id TAA13251; Wed, 27 Feb 2002 19:09:24 +1100 Date: Wed, 27 Feb 2002 19:09:52 +1100 (EST) From: Bruce Evans X-X-Sender: To: Peter Wemm Cc: Peter Dufault , "M. Warner Losh" , , Subject: Re: HEADS UP: cvs commit: src/sys/conf kern.pre.mk (fwd) In-Reply-To: <20020226233640.BEDA93BB0@overcee.wemm.org> Message-ID: <20020227190027.Y47861-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Tue, 26 Feb 2002, Peter Wemm wrote: > Peter Dufault wrote: > > 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. Sort of. __DECONST() is not ugly enough, and even its implementations are not ugly enough to be as correct as possible (spot the missing cast). I was recently forced to "fix" a warning that was "fixed" using the uintptr_t hack (missing a cast of course) in -current but not in my version (pending a better fix). Index: link_elf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/link_elf.c,v retrieving revision 1.51 diff -u -2 -r1.51 link_elf.c --- link_elf.c 16 Nov 2001 21:08:37 -0000 1.51 +++ link_elf.c 27 Feb 2002 06:34:38 -0000 @@ -839,8 +840,9 @@ elf_file_t ef = (elf_file_t) file; -#ifdef DDB +#if defined(DDB) && defined(__ELF__) if (ef->gdb.l_ld) { GDB_STATE(RT_DELETE); - free((void *)(uintptr_t)ef->gdb.l_name, M_LINKER); + /* XXX extreme ugliness to avoid a cast-qual warning: */ + free((void *)(uintptr_t)(const void *)ef->gdb.l_name, M_LINKER); link_elf_delete_gdb(&ef->gdb); GDB_STATE(RT_CONSISTENT); Is this ugly enough? Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message