Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Goncalo Gomes <goncalo@promisc.org>
To: gdb-patches@sourceware.org
Subject: Refactor tdep-i386.c to fix all -Wshadow warnings
Date: Sun, 05 Aug 2012 22:24:00 -0000	[thread overview]
Message-ID: <CADF=+bYpAVcM2OsyGypeGjo2uV3_-mu6YphQgYrwUHY+wMOiaQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

The attached patch fixes all warnings in tdep-i386.c resulting from
enabling shadow warnings in gcc. As this is my first contribution to
GDB, I decided to keep it short to a single file to obtain feedback.

2012-08-05  Goncalo Gomes <goncalo@promisc.org>

        * Refactor tdep-i386.c to fix all -Wshadow warnings

Goncalo

[-- Attachment #2: enable-gcc-shadow-warnings-0001.patch --]
[-- Type: application/octet-stream, Size: 5004 bytes --]

diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 0c59a25..9c47a7b 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -145,9 +145,9 @@ int exceptions_state_mc_action_iter_1 (void);
 
 #define TRY_CATCH(EXCEPTION,MASK) \
      { \
-       EXCEPTIONS_SIGJMP_BUF *buf = \
+       EXCEPTIONS_SIGJMP_BUF *_trycatch_sjbuf = \
 	 exceptions_state_mc_init (&(EXCEPTION), (MASK)); \
-       EXCEPTIONS_SIGSETJMP (*buf); \
+       EXCEPTIONS_SIGSETJMP (*_trycatch_sjbuf); \
      } \
      while (exceptions_state_mc_action_iter ()) \
        while (exceptions_state_mc_action_iter_1 ())
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 84e9794..6fbc51f 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2336,7 +2336,7 @@ i386_16_byte_align_p (struct type *type)
 
 static CORE_ADDR
 i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
-		      struct value **args, int nargs, struct type *value_type,
+		      struct value **args, int nargs, struct type *valtype,
 		      CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
 		      struct regcache *regcache)
 {
@@ -2514,7 +2514,7 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
-      ULONGEST fstat;
+      ULONGEST fpstat;
       gdb_byte buf[I386_MAX_REGISTER_SIZE];
 
       if (tdep->st0_regnum < 0)
@@ -2538,9 +2538,9 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
          actual value doesn't really matter, but 7 is what a normal
          function return would end up with if the program started out
          with a freshly initialized FPU.  */
-      regcache_raw_read_unsigned (regcache, I387_FSTAT_REGNUM (tdep), &fstat);
-      fstat |= (7 << 11);
-      regcache_raw_write_unsigned (regcache, I387_FSTAT_REGNUM (tdep), fstat);
+      regcache_raw_read_unsigned (regcache, I387_FSTAT_REGNUM (tdep), &fpstat);
+      fpstat |= (7 << 11);
+      regcache_raw_write_unsigned (regcache, I387_FSTAT_REGNUM (tdep), fpstat);
 
       /* Mark %st(1) through %st(7) as empty.  Since we set the top of
          the floating-point register stack to 7, the appropriate value
@@ -2825,12 +2825,12 @@ i386_mmx_regnum_to_fp_regnum (struct regcache *regcache, int regnum)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
   int mmxreg, fpreg;
-  ULONGEST fstat;
+  ULONGEST fpstat;
   int tos;
 
   mmxreg = regnum - tdep->mm0_regnum;
-  regcache_raw_read_unsigned (regcache, I387_FSTAT_REGNUM (tdep), &fstat);
-  tos = (fstat >> 11) & 0x7;
+  regcache_raw_read_unsigned (regcache, I387_FSTAT_REGNUM (tdep), &fpstat);
+  tos = (fpstat >> 11) & 0x7;
   fpreg = (mmxreg + tos) % 8;
 
   return (I387_ST0_REGNUM (tdep) + fpreg);
@@ -3561,7 +3561,7 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
 		  const char *start;
 		  char *base;
 		  int len_base;
-		  char *index;
+		  char *idx;
 		  int len_index;
 		  struct stoken base_token, index_token;
 
@@ -3609,15 +3609,15 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
 		    ++s;
 
 		  len_index = s - start;
-		  index = alloca (len_index + 1);
-		  strncpy (index, start, len_index);
-		  index[len_index] = '\0';
+		  idx = alloca (len_index + 1);
+		  strncpy (idx, start, len_index);
+		  idx[len_index] = '\0';
 
 		  if (user_reg_map_name_to_regnum (gdbarch,
-						   index, len_index) == -1)
+						   idx, len_index) == -1)
 		    error (_("Invalid register name `%s' "
 			     "on expression `%s'."),
-			   index, p->saved_arg);
+			   idx, p->saved_arg);
 
 		  if (*s != ',' && *s != ')')
 		    break;
@@ -3662,7 +3662,7 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
 		    write_exp_elt_opcode (BINOP_ADD);
 
 		  write_exp_elt_opcode (OP_REGISTER);
-		  index_token.ptr = index;
+		  index_token.ptr = idx;
 		  index_token.length = len_index;
 		  write_exp_string (index_token);
 		  write_exp_elt_opcode (OP_REGISTER);
@@ -3970,7 +3970,7 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
       int havesib = 0;
       uint8_t scale = 0;
       uint8_t byte;
-      uint8_t index = 0;
+      uint8_t idx = 0;
       uint8_t base = irp->rm;
 
       if (base == 4)
@@ -3980,7 +3980,7 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
 	    return -1;
 	  irp->addr++;
 	  scale = (byte >> 6) & 3;
-	  index = ((byte >> 3) & 7) | irp->rex_x;
+	  idx = ((byte >> 3) & 7) | irp->rex_x;
 	  base = (byte & 7);
 	}
       base |= irp->rex_b;
@@ -4028,9 +4028,9 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
       else
         *addr = (uint32_t) (offset64 + *addr);
 
-      if (havesib && (index != 4 || scale != 0))
+      if (havesib && (idx != 4 || scale != 0))
 	{
-	  regcache_raw_read_unsigned (irp->regcache, irp->regmap[index],
+	  regcache_raw_read_unsigned (irp->regcache, irp->regmap[idx],
                                       &offset64);
 	  if (irp->aflag == 2)
 	    *addr += offset64 << scale;

[-- Attachment #3: enable-gcc-shadow-warnings-0001.changelog --]
[-- Type: application/octet-stream, Size: 110 bytes --]

2012-08-05  Goncalo Gomes <goncalo@promisc.org>

        * Refactor tdep-i386.c to fix all -Wshadow warnings


             reply	other threads:[~2012-08-05 22:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-05 22:24 Goncalo Gomes [this message]
2012-08-06 10:46 ` Sergio Durigan Junior
2012-08-06 13:34   ` Goncalo Gomes
2012-08-06 14:23 ` Tom Tromey
2012-08-06 17:18   ` Goncalo Gomes
2012-08-06 19:40   ` Sergio Durigan Junior
2012-08-09  9:21   ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADF=+bYpAVcM2OsyGypeGjo2uV3_-mu6YphQgYrwUHY+wMOiaQ@mail.gmail.com' \
    --to=goncalo@promisc.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox