Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [committed] Remove a redundant condition check in tic6x-linux-tdep.c
@ 2012-11-30  7:35 Yao Qi
  2012-11-30 12:22 ` Mark Kettenis
  0 siblings, 1 reply; 4+ messages in thread
From: Yao Qi @ 2012-11-30  7:35 UTC (permalink / raw)
  To: gdb-patches

Hi,
When gdb is configured as target=tic6x-uclinux, and compiled with clang,
I get this warning:

gdb/tic6x-linux-tdep.c:66:19: error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-compare]

It is redundant to check 'REGNUM >= 0' as it is unsigned.  The
following patch is to fix it.  Committed.

gdb:

2012-11-30  Yao Qi  <yao@codesourcery.com>

	* tic6x-linux-tdep.c (tic6x_register_sigcontext_offset): Don't
	check REGNUM >= 0.
---
 gdb/tic6x-linux-tdep.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c
index 3b96201..f4450c9 100644
--- a/gdb/tic6x-linux-tdep.c
+++ b/gdb/tic6x-linux-tdep.c
@@ -63,7 +63,7 @@ tic6x_register_sigcontext_offset (unsigned int regnum, struct gdbarch *gdbarch)
   else if (regnum == TIC6X_B5_REGNUM || regnum == TIC6X_B5_REGNUM + 2
 	   || regnum == TIC6X_B5_REGNUM + 4)
     return 4 * (regnum - TIC6X_B5_REGNUM + 19);	/* B5, B7, B9 */
-  else if (regnum >= 0 && regnum < TIC6X_A4_REGNUM)
+  else if (regnum < TIC6X_A4_REGNUM)
     return 4 * (regnum - 0 + 8);	/* A0 - A3 */
   else if (regnum >= TIC6X_B0_REGNUM && regnum < TIC6X_B4_REGNUM)
     return 4 * (regnum - TIC6X_B0_REGNUM + 15);	/* B0 - B3 */
-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [committed] Remove a redundant condition check in tic6x-linux-tdep.c
  2012-11-30  7:35 [committed] Remove a redundant condition check in tic6x-linux-tdep.c Yao Qi
@ 2012-11-30 12:22 ` Mark Kettenis
  2012-11-30 14:11   ` Yao Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2012-11-30 12:22 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> From: Yao Qi <yao@codesourcery.com>
> Date: Fri, 30 Nov 2012 15:35:22 +0800
> 
> Hi,
> When gdb is configured as target=tic6x-uclinux, and compiled with clang,
> I get this warning:
> 
> gdb/tic6x-linux-tdep.c:66:19: error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-compare]
> 
> It is redundant to check 'REGNUM >= 0' as it is unsigned.  The
> following patch is to fix it.  Committed.

Hmm, well, perhaps the regnum variable should just be made signed.
That's typically what we use for register numbers, since -1 has the
special meaning of "all registers"/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [committed] Remove a redundant condition check in tic6x-linux-tdep.c
  2012-11-30 12:22 ` Mark Kettenis
@ 2012-11-30 14:11   ` Yao Qi
  2012-12-05 18:30     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Yao Qi @ 2012-11-30 14:11 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On 11/30/2012 08:22 PM, Mark Kettenis wrote:
> Hmm, well, perhaps the regnum variable should just be made signed.
> That's typically what we use for register numbers, since -1 has the
> special meaning of "all registers"/

Mark,
This patch is to change function tic6x_register_sigcontext_offset, which 
is to get the input REGNUM, and return the offset of corresponding 
register in 'struct sigcontext'.  So -1 means 'all registers' doesn't 
apply here.

Thank for reminding me this, I don't know -1 means 'all registers' before.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [committed] Remove a redundant condition check in tic6x-linux-tdep.c
  2012-11-30 14:11   ` Yao Qi
@ 2012-12-05 18:30     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2012-12-05 18:30 UTC (permalink / raw)
  To: Yao Qi; +Cc: Mark Kettenis, gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> This patch is to change function tic6x_register_sigcontext_offset,
Yao> which is to get the input REGNUM, and return the offset of
Yao> corresponding register in 'struct sigcontext'.  So -1 means 'all
Yao> registers' doesn't apply here.

Yao> Thank for reminding me this, I don't know -1 means 'all registers' before.

I suppose it is possible to change all the unsigned ints to ints in that
spot, but overall I think it is clearer with unsigned.

Tom


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-05 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-30  7:35 [committed] Remove a redundant condition check in tic6x-linux-tdep.c Yao Qi
2012-11-30 12:22 ` Mark Kettenis
2012-11-30 14:11   ` Yao Qi
2012-12-05 18:30     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox