Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/microblaze-tdep.c: Check whether less than zero in conditional expression
@ 2014-07-20 15:01 Chen Gang
  2014-07-23 21:27 ` Michael Eager
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2014-07-20 15:01 UTC (permalink / raw)
  To: eager; +Cc: binutils, gdb-patches

Use typecast 'size_t' on 'reg', not only avoid the related warning, but
also check whether less than zero -- for 'reg' is type 'int', and sizeof
(dwarf2_to_reg_map) is less than 0x7fff.

It is quoted in gdb_assert(), so need check 'reg' whether less than zero.
And the related warning (with '-W'):

  ../../binutils-gdb/gdb/microblaze-tdep.c:667:3: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

ChangeLog:

 * microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Check whether
 less tha zero in conditional expression.


Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 gdb/microblaze-tdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 7e89241..9bec260 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -664,7 +664,7 @@ static int dwarf2_to_reg_map[78] =
 static int
 microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  gdb_assert (reg < sizeof (dwarf2_to_reg_map));
+  gdb_assert ((size_t) reg < sizeof (dwarf2_to_reg_map));
   return dwarf2_to_reg_map[reg];
 }
 
-- 
1.7.11.7


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

end of thread, other threads:[~2014-07-31 18:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-20 15:01 [PATCH] gdb/microblaze-tdep.c: Check whether less than zero in conditional expression Chen Gang
2014-07-23 21:27 ` Michael Eager
2014-07-23 22:17   ` Chen Gang
2014-07-23 22:20     ` Michael Eager
2014-07-24  0:40       ` Chen Gang
2014-07-24  2:01         ` Chen Gang
2014-07-24  2:29           ` Michael Eager
2014-07-24  8:25             ` Chen Gang
2014-07-31 19:10     ` Chen Gang

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