[08/10] sim/h8300: avoid self assignment

Message ID cd6b7c00ffe44b4b56a9b92262336031524e2c2f.1666192979.git.aburgess@redhat.com
State Committed
Commit da8b81754bcd9eb2e45cec4997770a591cc61a8f
Headers
Series Building the sim/ tree with clang |

Commit Message

Andrew Burgess Oct. 19, 2022, 3:24 p.m. UTC
  There are two places in the h8300 simulator where we assign a variable
to itself.  Clang gives a warning for this, which is converted into an
error by -Werror.

Silence the warning by removing the self assignments.  As these
assignments were in a complex if/then/else tree, rather than try to
adjust all the conditions, I've just replaced the self assignments
with a comment and an empty statement.
---
 sim/h8300/compile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 1:52 p.m. UTC | #1
lgtm
-mike
  
Andrew Burgess Oct. 24, 2022, 4:26 p.m. UTC | #2
Mike Frysinger <vapier@gentoo.org> writes:

> lgtm

Pushed.

Thanks,
Andrew
  

Patch

diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 9be7dd565a9..5f64b4752f0 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -4141,7 +4141,7 @@  step_once (SIM_DESC sd, SIM_CPU *cpu)
 	  res = GET_B_REG (code->src.reg);	/* FIXME fetch? */
 	  if (!c && (0 <= (res >>  4) && (res >>  4) <= 9) && 
 	      !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
-	    res = res;		/* Value added == 0.  */
+	    /* Nothing.  */;		/* Value added == 0.  */
 	  else if (!c && (0  <= (res >>  4) && (res >>  4) <=  8) && 
 		   !h && (10 <= (res & 0xf) && (res & 0xf) <= 15))
 	    res = res + 0x6;		/* Value added == 6.  */
@@ -4174,7 +4174,7 @@  step_once (SIM_DESC sd, SIM_CPU *cpu)
 	  res = GET_B_REG (code->src.reg); /* FIXME fetch, fetch2... */
 	  if (!c && (0 <= (res >>  4) && (res >>  4) <= 9) && 
 	      !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
-	    res = res;		/* Value added == 0.  */
+	    /* Nothing.  */;		/* Value added == 0.  */
 	  else if (!c && (0 <= (res >>  4) && (res >>  4) <=  8) && 
 		    h && (6 <= (res & 0xf) && (res & 0xf) <= 15))
 	    res = res + 0xfa;		/* Value added == 0xfa.  */