sim: sh: fix switch-bool warnings
authorMike Frysinger <vapier@gentoo.org>
Fri, 12 Nov 2021 00:36:28 +0000 (19:36 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 13 Nov 2021 05:57:00 +0000 (00:57 -0500)
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

index 93923fa2c56c72858994be320596fd925b56486a..559b39a63226592ccd75b4294594dfc0dfea2957 100644 (file)
@@ -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);