Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] sim: sh: fix switch-bool warnings
Date: Thu, 11 Nov 2021 19:39:33 -0500	[thread overview]
Message-ID: <20211112003933.3612-2-vapier@gentoo.org> (raw)
In-Reply-To: <20211112003933.3612-1-vapier@gentoo.org>

This code triggers -Werror=switch-bool warnings with <=gcc-5 versions.
Rework it to use if statements instead as it also simplifies a bit.
---
 sim/sh/interp.c | 79 ++++++++++++++++++-------------------------------
 1 file changed, 28 insertions(+), 51 deletions(-)

diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 93923fa2c56c..559b39a63226 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1104,74 +1104,51 @@ div1 (int *R, int iRn2, int iRn1/*, int T*/)
   R[iRn1] <<= 1;
   R[iRn1] |= (unsigned long) T;
 
-  switch (old_q)
+  if (!old_q)
     {
-    case 0:
-      switch (M)
+      if (!M)
 	{
-	case 0:
 	  tmp0 = R[iRn1];
 	  R[iRn1] -= R[iRn2];
 	  tmp1 = (R[iRn1] > tmp0);
-	  switch (Q)
-	    {
-	    case 0:
-	      SET_SR_Q (tmp1);
-	      break;
-	    case 1:
-	      SET_SR_Q ((unsigned char) (tmp1 == 0));
-	      break;
-	    }
-	  break;
-	case 1:
+	  if (!Q)
+	    SET_SR_Q (tmp1);
+	  else
+	    SET_SR_Q ((unsigned char) (tmp1 == 0));
+	}
+      else
+	{
 	  tmp0 = R[iRn1];
 	  R[iRn1] += R[iRn2];
 	  tmp1 = (R[iRn1] < tmp0);
-	  switch (Q)
-	    {
-	    case 0:
-	      SET_SR_Q ((unsigned char) (tmp1 == 0));
-	      break;
-	    case 1:
-	      SET_SR_Q (tmp1);
-	      break;
-	    }
-	  break;
+	  if (!Q)
+	    SET_SR_Q ((unsigned char) (tmp1 == 0));
+	  else
+	    SET_SR_Q (tmp1);
 	}
-      break;
-    case 1:
-      switch (M)
+    }
+  else
+    {
+      if (!M)
 	{
-	case 0:
 	  tmp0 = R[iRn1];
 	  R[iRn1] += R[iRn2];
 	  tmp1 = (R[iRn1] < tmp0);
-	  switch (Q)
-	    {
-	    case 0:
-	      SET_SR_Q (tmp1);
-	      break;
-	    case 1:
-	      SET_SR_Q ((unsigned char) (tmp1 == 0));
-	      break;
-	    }
-	  break;
-	case 1:
+	  if (!Q)
+	    SET_SR_Q (tmp1);
+	  else
+	    SET_SR_Q ((unsigned char) (tmp1 == 0));
+	}
+      else
+	{
 	  tmp0 = R[iRn1];
 	  R[iRn1] -= R[iRn2];
 	  tmp1 = (R[iRn1] > tmp0);
-	  switch (Q)
-	    {
-	    case 0:
-	      SET_SR_Q ((unsigned char) (tmp1 == 0));
-	      break;
-	    case 1:
-	      SET_SR_Q (tmp1);
-	      break;
-	    }
-	  break;
+	  if (!Q)
+	    SET_SR_Q ((unsigned char) (tmp1 == 0));
+	  else
+	    SET_SR_Q (tmp1);
 	}
-      break;
     }
   /*T = (Q == M);*/
   SET_SR_T (Q == M);
-- 
2.33.0


      reply	other threads:[~2021-11-12  0:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-07  0:32 [PATCH 1/6] sim: sh: rework register layout with anonymous unions & structs Mike Frysinger via Gdb-patches
2021-11-07  0:32 ` [PATCH 2/6] sim: sh: fix unused-value warnings Mike Frysinger via Gdb-patches
2021-11-07  0:32 ` [PATCH 3/6] sim: sh: fix various parentheses warnings Mike Frysinger via Gdb-patches
2021-11-07  0:32 ` [PATCH 4/6] sim: sh: constify a few read-only lookup tables Mike Frysinger via Gdb-patches
2021-11-07  0:32 ` [PATCH 5/6] sim: sh: fix uninitialized variable usage with pdmsb Mike Frysinger via Gdb-patches
2021-11-07  0:32 ` [PATCH 6/6] sim: sh: enable -Werror everywhere Mike Frysinger via Gdb-patches
2021-11-11 12:41 ` [PATCH 1/6] sim: sh: rework register layout with anonymous unions & structs Luis Machado via Gdb-patches
2021-11-11 22:25   ` Mike Frysinger via Gdb-patches
2021-11-11 22:32     ` Luis Machado via Gdb-patches
2021-11-11 22:38       ` Luis Machado via Gdb-patches
2021-11-11 22:45       ` Mike Frysinger via Gdb-patches
2021-11-12 13:12         ` Luis Machado via Gdb-patches
2021-11-12  0:39   ` [PATCH 1/2] sim: sh: rework carry checks to not rely on integer overflows Mike Frysinger via Gdb-patches
2021-11-12  0:39     ` Mike Frysinger via Gdb-patches [this message]

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=20211112003933.3612-2-vapier@gentoo.org \
    --to=gdb-patches@sourceware.org \
    --cc=vapier@gentoo.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