This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Fix cygwin32 failure introduced by [patch] windows-nat.c: Fix offset problem in signal string handling
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>
- Cc: brobecker at adacore dot com, gdb-patches at sourceware dot org, vinschen at redhat dot com
- Date: Wed, 27 Mar 2013 12:46:45 +0200
- Subject: Re: [RFA] Fix cygwin32 failure introduced by [patch] windows-nat.c: Fix offset problem in signal string handling
- References: <20130319151436 dot GB20727 at calimero dot vinschen dot de> <20130319212554 dot GE4506 at adacore dot com> <000101ce2a6b$8c855a60$a5900f20$%muller at ics-cnrs dot unistra dot fr> <83y5d9xrqt dot fsf at gnu dot org> <005501ce2ac8$ae830150$0b8903f0$%muller at ics-cnrs dot unistra dot fr>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> Cc: <brobecker@adacore.com>, <gdb-patches@sourceware.org>, <vinschen@redhat.com>
> Date: Wed, 27 Mar 2013 09:54:23 +0100
>
> ../../src/gdb/windows-nat.c: In function 'handle_output_debug_string':
> ../../src/gdb/windows-nat.c:993:16: erreur: assignment makes pointer from integer without a cast
Right. But IMO the casts here are dubious to begin with. strtoull
produces a 64-bit value; casting it to a 32-bit uintptr_t might shut
up the compiler, but it doesn't solve the fundamental problem, which
is that a 64-bit value is being stuffed into a 32-bit wide pointer.
A cleaner way would be something like
sscanf (p, "%p", &x);
If that doesn't satisfy the compiler, either, then the following code,
which explicitly resets should be better than the double casts, IMO:
unsigned long xul;
...
xul = strtoull (p, NULL, 0) & ~((DWORD_PTR)0);
x = (LPCVOID) xul;
P.S. Yes, I hate casts, because they tend to conceal subtle bugs.