Date: Wed, 27 Feb 2002 19:09:52 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Peter Wemm <peter@wemm.org> Cc: Peter Dufault <dufault@hda.hda.com>, "M. Warner Losh" <imp@village.org>, <mike_makonnen@yahoo.com>, <current@FreeBSD.ORG> Subject: Re: HEADS UP: cvs commit: src/sys/conf kern.pre.mk (fwd) Message-ID: <20020227190027.Y47861-100000@gamplex.bde.org> In-Reply-To: <20020226233640.BEDA93BB0@overcee.wemm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020227190027.Y47861-100000>
