]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix GCC 7 -Wimplicit-fallthrough warnings
authorAndreas Stieger <astieger@suse.com>
Sun, 28 May 2017 21:49:31 +0000 (23:49 +0200)
committerNick Mathewson <nickm@torproject.org>
Mon, 11 Sep 2017 21:47:04 +0000 (17:47 -0400)
Add magic comments recognized by default -Wimplicit-fallthrough=3
or break, as required.

src/ext/csiphash.c
src/ext/ed25519/donna/modm-donna-64bit.h
src/or/buffers.c
src/or/connection_edge.c
src/or/dns.c
src/or/relay.c

index b60f73a7fffe60b32aa0546c65d74a9bf9303108..49a6dc47789f6de5f0c6d794ab9ccb489f9c8dd5 100644 (file)
@@ -122,13 +122,13 @@ uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *k
        }
 
        switch (src_sz - blocks) {
-               case 7: last7 |= (uint64_t)m[i + 6] << 48;
-               case 6: last7 |= (uint64_t)m[i + 5] << 40;
-               case 5: last7 |= (uint64_t)m[i + 4] << 32;
-               case 4: last7 |= (uint64_t)m[i + 3] << 24;
-               case 3: last7 |= (uint64_t)m[i + 2] << 16;
-               case 2: last7 |= (uint64_t)m[i + 1] <<  8;
-               case 1: last7 |= (uint64_t)m[i + 0]      ;
+               case 7: last7 |= (uint64_t)m[i + 6] << 48; /* Falls through. */
+               case 6: last7 |= (uint64_t)m[i + 5] << 40; /* Falls through. */
+               case 5: last7 |= (uint64_t)m[i + 4] << 32; /* Falls through. */
+               case 4: last7 |= (uint64_t)m[i + 3] << 24; /* Falls through. */
+               case 3: last7 |= (uint64_t)m[i + 2] << 16; /* Falls through. */
+               case 2: last7 |= (uint64_t)m[i + 1] <<  8; /* Falls through. */
+               case 1: last7 |= (uint64_t)m[i + 0]      ; /* Falls through. */
                case 0:
                default:;
        }
index 012ea9ea0845f21650bc35b01b46200d1e096082..06c98e30395142a8cd6708f740d5241d8dba40d6 100644 (file)
@@ -294,10 +294,10 @@ sub256_modm_batch(bignum256modm out, const bignum256modm a, const bignum256modm
        size_t i = 0;
        bignum256modm_element_t carry = 0;
        switch (limbsize) {
-               case 4: out[i] = (a[i] - b[i])        ; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
-               case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
-               case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
-               case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
+               case 4: out[i] = (a[i] - b[i])        ; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
+               case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
+               case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
+               case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
                case 0: 
                default: out[i] = (a[i] - b[i]) - carry;
        }
@@ -310,10 +310,10 @@ lt256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize)
        size_t i = 0;
        bignum256modm_element_t t, carry = 0;
        switch (limbsize) {
-               case 4: t = (a[i] - b[i])        ; carry = (t >> 63); i++;
-               case 3: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++;
-               case 2: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++;
-               case 1: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++;
+               case 4: t = (a[i] - b[i])        ; carry = (t >> 63); i++; /* Falls through. */
+               case 3: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+               case 2: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+               case 1: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
                case 0: t = (a[i] - b[i]) - carry; carry = (t >> 63);
        }
        return (int)carry;
@@ -325,10 +325,10 @@ lte256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize)
        size_t i = 0;
        bignum256modm_element_t t, carry = 0;
        switch (limbsize) {
-               case 4: t = (b[i] - a[i])        ; carry = (t >> 63); i++;
-               case 3: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++;
-               case 2: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++;
-               case 1: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++;
+               case 4: t = (b[i] - a[i])        ; carry = (t >> 63); i++; /* Falls through. */
+               case 3: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+               case 2: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+               case 1: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
                case 0: t = (b[i] - a[i]) - carry; carry = (t >> 63);
        }
        return (int)!carry;
index 8981fd283bf5a0aa697d5630229dbc98376297dd..89382d1d8e565ed5bde8f2f28f52b1368185d978 100644 (file)
@@ -1595,6 +1595,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
           return -1;
       }
       tor_assert(0);
+      break;
     case 4: { /* socks4 */
       enum {socks4, socks4a} socks4_prot = socks4a;
       const char *authstart, *authend;
index 53ade173df3a33e4b1b6d20115a6192be33d3502..12fe2f57c97fdbda0653a2e1b4f05f8a7ffa9a98 100644 (file)
@@ -260,6 +260,7 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
       }
       /* Fall through if the connection is on a circuit without optimistic
        * data support. */
+      /* Falls through. */
     case EXIT_CONN_STATE_CONNECTING:
     case AP_CONN_STATE_RENDDESC_WAIT:
     case AP_CONN_STATE_CIRCUIT_WAIT:
index e007a402f4edc832f6738d54943a81dc643a27ae..0ad4c0f5056d9a5934fffa9c0f5f6393ceef5d88 100644 (file)
@@ -522,6 +522,7 @@ send_resolved_cell,(edge_connection_t *conn, uint8_t answer_type,
         answer_type = RESOLVED_TYPE_ERROR;
         /* fall through. */
       }
+      /* Falls through. */
     case RESOLVED_TYPE_ERROR_TRANSIENT:
     case RESOLVED_TYPE_ERROR:
       {
index 4e9dadba16c941a6842294704c0c0ce8874a71da..882877ade3999664e472f86f9e5225934abe28f4 100644 (file)
@@ -859,6 +859,7 @@ connection_ap_process_end_not_open(
           break; /* break means it'll close, below */
         /* Else fall through: expire this circuit, clear the
          * chosen_exit_name field, and try again. */
+        /* Falls through. */
       case END_STREAM_REASON_RESOLVEFAILED:
       case END_STREAM_REASON_TIMEOUT:
       case END_STREAM_REASON_MISC: