]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix GCC 7 -Wimplicit-fallthrough warnings (32 bit)
authorAndreas Stieger <astieger@suse.com>
Wed, 31 May 2017 09:54:11 +0000 (11:54 +0200)
committerNick Mathewson <nickm@torproject.org>
Mon, 11 Sep 2017 21:45:07 +0000 (17:45 -0400)
Add magic comments recognized by default -Wimplicit-fallthrough=3
Follow-up to e5f464, fixes Ticket 22446 for 32 bit.

[nick notes: Backport from 0.3.1.3-alpha.]

changes/bug22446 [new file with mode: 0644]
src/ext/ed25519/donna/modm-donna-32bit.h

diff --git a/changes/bug22446 b/changes/bug22446
new file mode 100644 (file)
index 0000000..eab65aa
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features (code style, backport from 0.3.1.3-alpha):
+    - Add "Falls through" comments to our codebase, in order to silence
+      GCC 7's -Wimplicit-fallthrough warnings. Patch from Andreas
+      Stieger. Closes ticket 22446.
index 5f36df655d5cd44f17a4cac53748bc19d4c52f39..0ef9e58fa16abe2d92f09fb48b307fe8b152823f 100644 (file)
@@ -385,14 +385,14 @@ sub256_modm_batch(bignum256modm out, const bignum256modm a, const bignum256modm
        size_t i = 0;
        bignum256modm_element_t carry = 0;
        switch (limbsize) {
-               case 8: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 7: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 6: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 5: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 4: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-               case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
+               case 8: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 7: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 6: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 5: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 4: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+               case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
                case 0: 
                default: out[i] = (a[i] - b[i]) - carry;
        }
@@ -403,14 +403,14 @@ sub256_modm_batch(bignum256modm out, const bignum256modm a, const bignum256modm
 static int
 lt256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize) {
        switch (limbsize) {
-               case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1;
-               case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1;
-               case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1;
-               case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1;
-               case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1;
-               case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1;
-               case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1;
-               case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1;
+               case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1; /* Falls through. */
+               case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1; /* Falls through. */
+               case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1; /* Falls through. */
+               case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1; /* Falls through. */
+               case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1; /* Falls through. */
+               case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1; /* Falls through. */
+               case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1; /* Falls through. */
+               case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1; /* Falls through. */
                case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
        }
        return 0;
@@ -420,14 +420,14 @@ lt256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize)
 static int
 lte256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize) {
        switch (limbsize) {
-               case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1;
-               case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1;
-               case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1;
-               case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1;
-               case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1;
-               case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1;
-               case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1;
-               case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1;
+               case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1; /* Falls through. */
+               case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1; /* Falls through. */
+               case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1; /* Falls through. */
+               case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1; /* Falls through. */
+               case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1; /* Falls through. */
+               case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1; /* Falls through. */
+               case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1; /* Falls through. */
+               case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1; /* Falls through. */
                case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
        }
        return 1;