public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 06/15] sim: erc32: fix -Wshadow=local warnings
Date: Thu, 21 Dec 2023 20:23:46 -0500	[thread overview]
Message-ID: <20231222012355.7504-6-vapier@gentoo.org> (raw)
In-Reply-To: <20231222012355.7504-1-vapier@gentoo.org>

Rename shadowed vars with different types to avoid confusion.
---
 sim/erc32/exec.c | 63 ++++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 32 deletions(-)

diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c
index 10a9dae603c0..c8186df02f1d 100644
--- a/sim/erc32/exec.c
+++ b/sim/erc32/exec.c
@@ -707,7 +707,7 @@ dispatch_instruction(struct pstate *sregs)
 	    case DIVScc:
 		{
 		  int sign;
-		  uint32_t result, remainder;
+		  uint32_t uresult, remainder;
 		  int c0, y31;
 
 		  if (!sparclite) {
@@ -723,7 +723,7 @@ dispatch_instruction(struct pstate *sregs)
 		     Otherwise, calculate remainder + divisor.  */
 		  if (sign == 0)
 		    operand2 = ~operand2 + 1;
-		  result = remainder + operand2;
+		  uresult = remainder + operand2;
 
 		  /* The SPARClite User's Manual is not clear on how
 		     the "carry out" of the above ALU operation is to
@@ -733,24 +733,23 @@ dispatch_instruction(struct pstate *sregs)
 		     even in cases where the divisor is subtracted
 		     from the remainder.  FIXME: get the true story
 		     from Fujitsu. */
-		  c0 = result < (uint32_t) remainder
-		       || result < (uint32_t) operand2;
+		  c0 = uresult < remainder || uresult < (uint32_t) operand2;
 
-		  if (result & 0x80000000)
+		  if (uresult & 0x80000000)
 		    sregs->psr |= PSR_N;
 		  else
 		    sregs->psr &= ~PSR_N;
 
 		  y31 = (sregs->y & 0x80000000) == 0x80000000;
 
-		  if (result == 0 && sign == y31)
+		  if (uresult == 0 && sign == y31)
 		    sregs->psr |= PSR_Z;
 		  else
 		    sregs->psr &= ~PSR_Z;
 
 		  sign = (sign && !y31) || (!c0 && (sign || !y31));
 
-		  if (sign ^ (result >> 31))
+		  if (sign ^ (uresult >> 31))
 		    sregs->psr |= PSR_V;
 		  else
 		    sregs->psr &= ~PSR_V;
@@ -760,7 +759,7 @@ dispatch_instruction(struct pstate *sregs)
 		  else
 		    sregs->psr &= ~PSR_C;
 
-		  sregs->y = result;
+		  sregs->y = uresult;
 
 		  if (rd != 0)
 		    *rdd = (rs1 << 1) | !sign;
@@ -773,21 +772,21 @@ dispatch_instruction(struct pstate *sregs)
 		break;
 	    case SMULCC:
 		{
-		  uint32_t result;
+		  uint32_t uresult;
 
-		  mul64 (rs1, operand2, &sregs->y, &result, 1);
+		  mul64 (rs1, operand2, &sregs->y, &uresult, 1);
 
-		  if (result & 0x80000000)
+		  if (uresult & 0x80000000)
 		    sregs->psr |= PSR_N;
 		  else
 		    sregs->psr &= ~PSR_N;
 
-		  if (result == 0)
+		  if (uresult == 0)
 		    sregs->psr |= PSR_Z;
 		  else
 		    sregs->psr &= ~PSR_Z;
 
-		  *rdd = result;
+		  *rdd = uresult;
 		}
 		break;
 	    case UMUL:
@@ -797,21 +796,21 @@ dispatch_instruction(struct pstate *sregs)
 		break;
 	    case UMULCC:
 		{
-		  uint32_t result;
+		  uint32_t uresult;
 
-		  mul64 (rs1, operand2, &sregs->y, &result, 0);
+		  mul64 (rs1, operand2, &sregs->y, &uresult, 0);
 
-		  if (result & 0x80000000)
+		  if (uresult & 0x80000000)
 		    sregs->psr |= PSR_N;
 		  else
 		    sregs->psr &= ~PSR_N;
 
-		  if (result == 0)
+		  if (uresult == 0)
 		    sregs->psr |= PSR_Z;
 		  else
 		    sregs->psr &= ~PSR_Z;
 
-		  *rdd = result;
+		  *rdd = uresult;
 		}
 		break;
 	    case SDIV:
@@ -831,7 +830,7 @@ dispatch_instruction(struct pstate *sregs)
 		break;
 	    case SDIVCC:
 		{
-		  uint32_t result;
+		  uint32_t uresult;
 
 		  if (sparclite) {
 		     sregs->trap = TRAP_UNIMP;
@@ -843,14 +842,14 @@ dispatch_instruction(struct pstate *sregs)
 		    break;
 		  }
 
-		  div64 (sregs->y, rs1, operand2, &result, 1);
+		  div64 (sregs->y, rs1, operand2, &uresult, 1);
 
-		  if (result & 0x80000000)
+		  if (uresult & 0x80000000)
 		    sregs->psr |= PSR_N;
 		  else
 		    sregs->psr &= ~PSR_N;
 
-		  if (result == 0)
+		  if (uresult == 0)
 		    sregs->psr |= PSR_Z;
 		  else
 		    sregs->psr &= ~PSR_Z;
@@ -858,7 +857,7 @@ dispatch_instruction(struct pstate *sregs)
 		  /* FIXME: should set overflow flag correctly.  */
 		  sregs->psr &= ~(PSR_C | PSR_V);
 
-		  *rdd = result;
+		  *rdd = uresult;
 		}
 		break;
 	    case UDIV:
@@ -878,7 +877,7 @@ dispatch_instruction(struct pstate *sregs)
 		break;
 	    case UDIVCC:
 		{
-		  uint32_t result;
+		  uint32_t uresult;
 
 		  if (sparclite) {
 		     sregs->trap = TRAP_UNIMP;
@@ -890,14 +889,14 @@ dispatch_instruction(struct pstate *sregs)
 		    break;
 		  }
 
-		  div64 (sregs->y, rs1, operand2, &result, 0);
+		  div64 (sregs->y, rs1, operand2, &uresult, 0);
 
-		  if (result & 0x80000000)
+		  if (uresult & 0x80000000)
 		    sregs->psr |= PSR_N;
 		  else
 		    sregs->psr &= ~PSR_N;
 
-		  if (result == 0)
+		  if (uresult == 0)
 		    sregs->psr |= PSR_Z;
 		  else
 		    sregs->psr &= ~PSR_Z;
@@ -905,7 +904,7 @@ dispatch_instruction(struct pstate *sregs)
 		  /* FIXME: should set overflow flag correctly.  */
 		  sregs->psr &= ~(PSR_C | PSR_V);
 
-		  *rdd = result;
+		  *rdd = uresult;
 		}
 		break;
 	    case IXNOR:
@@ -1168,7 +1167,7 @@ dispatch_instruction(struct pstate *sregs)
 
 	    case SCAN:
 		{
-		  uint32_t result, mask;
+		  uint32_t uresult, mask;
 		  int i;
 
 		  if (!sparclite) {
@@ -1176,12 +1175,12 @@ dispatch_instruction(struct pstate *sregs)
                      break;
 		  }
 		  mask = (operand2 & 0x80000000) | (operand2 >> 1);
-		  result = rs1 ^ mask;
+		  uresult = rs1 ^ mask;
 
 		  for (i = 0; i < 32; i++) {
-		    if (result & 0x80000000)
+		    if (uresult & 0x80000000)
 		      break;
-		    result <<= 1;
+		    uresult <<= 1;
 		  }
 
 		  *rdd = i == 32 ? 63 : i;
-- 
2.43.0


  parent reply	other threads:[~2023-12-22  1:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22  1:23 [PATCH 01/15] sim: aarch64: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 02/15] sim: arm: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 03/15] sim: bfin: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 04/15] sim: common: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 05/15] sim: cris: " Mike Frysinger
2023-12-22  1:23 ` Mike Frysinger [this message]
2023-12-22  1:23 ` [PATCH 07/15] sim: frv: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 08/15] sim: h8300: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 09/15] sim: iq2000: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 10/15] sim: m68hc11: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 11/15] sim: mips: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 12/15] sim: ppc: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 13/15] sim: riscv: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 14/15] sim: sh: " Mike Frysinger
2023-12-22  1:23 ` [PATCH 15/15] sim: warnings: enable -Wshadow=local Mike Frysinger
2023-12-22 15:26   ` Tom Tromey
2023-12-23  4:28 ` [PATCH] sim: m32c: fix -Wshadow=local warnings Mike Frysinger
2023-12-23  4:28 ` [PATCH] sim: cris: disable -Wshadow=local in generated mloop files Mike Frysinger

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=20231222012355.7504-6-vapier@gentoo.org \
    --to=vapier@gentoo.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).