]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
coverity: dead code and overflows
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 28 Mar 2024 08:06:23 +0000 (09:06 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 28 Mar 2024 08:06:23 +0000 (09:06 +0100)
Overflows deliberate. Dead code probably not.

VEX/priv/guest_amd64_helpers.c
VEX/priv/guest_arm64_toIR.c

index adb5c7287e5ed6ed51b77369955d6acea2158eb4..da1cabc3cb2044740027ef5ae31945b0e48dfdf5 100644 (file)
@@ -3662,7 +3662,6 @@ ULong amd64g_calculate_RCR ( ULong arg,
          }
          break;
       case 4:
-         while (tempCOUNT >= 33) tempCOUNT -= 33;
          cf        = (rflags_in >> AMD64G_CC_SHIFT_C) & 1;
          of        = ((arg >> 31) ^ cf) & 1;
          while (tempCOUNT > 0) {
@@ -3730,7 +3729,6 @@ ULong amd64g_calculate_RCL ( ULong arg,
          of = ((arg >> 63) ^ cf) & 1;
          break;
       case 4:
-         while (tempCOUNT >= 33) tempCOUNT -= 33;
          cf = (rflags_in >> AMD64G_CC_SHIFT_C) & 1;
          while (tempCOUNT > 0) {
             tempcf = (arg >> 31) & 1;
index 8a8743866b1667a99fc0a4d5bbed721b8ec8e01b..3b33c48c3e7a73495927901d9066f42cd7890b3d 100644 (file)
@@ -8047,8 +8047,13 @@ static Bool AdvSIMDExpandImm ( /*OUT*/ULong* res,
       case 1:
          testimm8 = True; imm64 = Replicate32x2(imm8 << 8UL); break;
       case 2:
+         // Coverity is right but we want the overflow, Replicate32x2 expects
+         // (and asserts) that the top 32bits be zero so if we get rid of the
+         // overflow we would need to add a mask. So just let it overflow.
+         // coverity[OVERFLOW_BEFORE_WIDEN:FALSE]
          testimm8 = True; imm64 = Replicate32x2(imm8 << 16UL); break;
       case 3:
+         // coverity[OVERFLOW_BEFORE_WIDEN:FALSE]
          testimm8 = True; imm64 = Replicate32x2(imm8 << 24UL); break;
       case 4:
           testimm8 = False; imm64 = Replicate16x4(imm8); break;