This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: Warning fixes
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: drow at false dot org
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 28 Dec 2006 23:56:06 +0100 (CET)
- Subject: Re: RFC: Warning fixes
- References: <20061228195828.GA18628@nevyn.them.org>
> Date: Thu, 28 Dec 2006 14:58:28 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> Any comments on these, or shall I commit them? Regardless of the configure
> patch, we might as well fix the bugs.
Some of these are really scary. Can you check for regressions on i386 Linux?
The only thing that bothers me is this one:
> Index: signals/signals.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/signals/signals.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 signals.c
> --- signals/signals.c 28 Nov 2006 19:45:07 -0000 1.11
> +++ signals/signals.c 28 Dec 2006 19:42:04 -0000
> @@ -219,7 +219,7 @@ static struct {
> char *
> target_signal_to_string (enum target_signal sig)
> {
> - if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
> + if (sig <= TARGET_SIGNAL_LAST)
> return signals[sig].string;
> else
> return signals[TARGET_SIGNAL_UNKNOWN].string;
> @@ -229,8 +229,7 @@ target_signal_to_string (enum target_sig
> char *
> target_signal_to_name (enum target_signal sig)
> {
> - if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST)
> - && signals[sig].name != NULL)
> + if (sig <= TARGET_SIGNAL_LAST && signals[sig].name != NULL)
> return signals[sig].name;
> else
> /* I think the code which prints this will always print it along
ISO C clearly states that enumeration constants have type 'int', so
sig could be negative, and we defenitely want to catch that case. If
GCC thinks it knows that (sig >= TARGET_SIGNAL_FIRST), I think it is
being too smart for its own good.
Mark