]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use __attribute__((fallthrough)) rather than magic GCC comments.
authorNick Mathewson <nickm@torproject.org>
Wed, 6 May 2020 14:45:48 +0000 (10:45 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 6 May 2020 20:53:40 +0000 (16:53 -0400)
GCC added an implicit-fallthrough warning a while back, where it
would complain if you had a nontrivial "case:" block that didn't end
with break, return, or something like that.  Clang recently added
the same thing.

GCC, however, would let you annotate a fall-through as intended by
any of various magic "/* fall through */" comments.  Clang, however,
only seems to like "__attribute__((fallthrough))".  Fortunately, GCC
accepts that too.

A previous commit in this branch defined a FALLTHROUGH macro to do
the right thing if GNUC is defined; here we replace all of our "fall
through" comments with uses of that macro.

This is an automated commit, made with the following perl one-liner:

  #!/usr/bin/perl -i -p
  s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;

(In order to avoid conflicts, I'm applying this script separately to
each maint branch. This is the 0.4.2 version.)

25 files changed:
src/core/or/channeltls.c
src/core/or/circuitbuild.c
src/core/or/circuitlist.c
src/core/or/circuituse.c
src/core/or/connection_edge.c
src/core/or/crypt_path.c
src/core/or/onion.c
src/core/or/policies.c
src/core/or/reasons.c
src/core/or/relay.c
src/core/or/scheduler.c
src/core/or/sendme.c
src/core/proto/proto_socks.c
src/ext/csiphash.c
src/ext/ed25519/donna/modm-donna-32bit.h
src/ext/ed25519/donna/modm-donna-64bit.h
src/feature/client/entrynodes.c
src/feature/control/control_cmd.c
src/feature/dirclient/dirclient.c
src/feature/dirparse/parsecommon.c
src/feature/relay/dns.c
src/feature/rend/rendclient.c
src/lib/crypt_ops/crypto_digest_nss.c
src/lib/crypt_ops/crypto_digest_openssl.c
src/test/test_socks.c

index e9497651efed9f1598937b855254ecca5a72cae0..d6c9e21631dada4eb47f97fb724df6b6ccb03928 100644 (file)
@@ -1237,7 +1237,7 @@ channel_tls_handle_var_cell(var_cell_t *var_cell, or_connection_t *conn)
       /* But that should be happening any longer've disabled bufferevents. */
       tor_assert_nonfatal_unreached_once();
 
-      /* fall through */
+      FALLTHROUGH;
     case OR_CONN_STATE_TLS_SERVER_RENEGOTIATING:
       if (!(command_allowed_before_handshake(var_cell->command))) {
         log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
index 1daf468715c12f84892a3b7d0d28349d4f551261..16bb7e7d7912e0ee10f43188edc4ce220ae683c1 100644 (file)
@@ -2108,7 +2108,7 @@ choose_good_exit_server(origin_circuit_t *circ,
       /* For these three, we want to pick the exit like a middle hop,
        * since it should be random. */
       tor_assert_nonfatal(is_internal);
-      /* Falls through */
+      FALLTHROUGH;
     case CIRCUIT_PURPOSE_C_GENERAL:
       if (is_internal) /* pick it like a middle hop */
         return router_choose_random_node(NULL, options->ExcludeNodes, flags);
index 9ee9f93c994816b23e7b2c78c81ac8916a4d4785..61bcfa903992346aac0bbf23100952b194c5b86c 100644 (file)
@@ -844,7 +844,7 @@ circuit_purpose_to_controller_hs_state_string(uint8_t purpose)
              "Unrecognized circuit purpose: %d",
              (int)purpose);
       tor_fragile_assert();
-      /* fall through */
+      FALLTHROUGH;
 
     case CIRCUIT_PURPOSE_OR:
     case CIRCUIT_PURPOSE_C_GENERAL:
index 606c5e2dd232c93c95a51ce0bcdaeaadb1591d03..284e315f9cb6a057f07284a84c3aa34268b7b5ae 100644 (file)
@@ -784,7 +784,7 @@ circuit_expire_building(void)
             TO_ORIGIN_CIRCUIT(victim)->build_state->pending_final_cpath ==
             NULL)
           break;
-        /* fallthrough! */
+        FALLTHROUGH;
       case CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT:
       case CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED:
         /* If we have reached this line, we want to spare the circ for now. */
index 5f1664d286f4f206d1114b58bdc86be9b2c8a4ca..4f5f038e6c35be1b69642959818d102dede30203 100644 (file)
@@ -307,7 +307,7 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
         note_user_activity(approx_time());
       }
 
-      /* falls through. */
+      FALLTHROUGH;
     case EXIT_CONN_STATE_OPEN:
       if (connection_edge_package_raw_inbuf(conn, package_partial, NULL) < 0) {
         /* (We already sent an end cell if possible) */
@@ -332,7 +332,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. */
+      FALLTHROUGH;
     case EXIT_CONN_STATE_CONNECTING:
     case AP_CONN_STATE_RENDDESC_WAIT:
     case AP_CONN_STATE_CIRCUIT_WAIT:
@@ -766,7 +766,7 @@ connection_edge_flushed_some(edge_connection_t *conn)
         note_user_activity(approx_time());
       }
 
-      /* falls through. */
+      FALLTHROUGH;
     case EXIT_CONN_STATE_OPEN:
       sendme_connection_edge_consider_sending(conn);
       break;
index 6d5245510fef53324993e05ddac60dab837ac7d5..9b7efc28bfdf66a8d1b16ff19da2a12e78b151fa 100644 (file)
@@ -113,7 +113,7 @@ cpath_assert_layer_ok(const crypt_path_t *cp)
     {
     case CPATH_STATE_OPEN:
       relay_crypto_assert_ok(&cp->pvt_crypto);
-      /* fall through */
+      FALLTHROUGH;
     case CPATH_STATE_CLOSED:
       /*XXXX Assert that there's no handshake_state either. */
       tor_assert(!cp->rend_dh_handshake_state);
index aa77465b967e12e5124c64eb49988bf32d4d13b1..aeddedd80749e06a92083b2d07c122a40f7b545f 100644 (file)
@@ -509,7 +509,7 @@ create_cell_format_impl(cell_t *cell_out, const create_cell_t *cell_in,
       p += 16;
       space -= 16;
     }
-    /* Fall through */
+    FALLTHROUGH;
   case CELL_CREATE_FAST:
     tor_assert(cell_in->handshake_len <= space);
     memcpy(p, cell_in->onionskin, cell_in->handshake_len);
index 83d9a53fc01993f6146fdf4713a689efede65d88..39a0817c85caed21f31ead699ac79df30657dedd 100644 (file)
@@ -2842,7 +2842,7 @@ parse_short_policy(const char *summary)
     switch (*next) {
       case ',':
         ++next;
-        /* fall through */
+        FALLTHROUGH;
       case '\0':
         high = low;
         break;
index a7952279ba01dc3bf01a26860aeed0497b872641..e21bfa670afe55b58520514c9f638a037b272709 100644 (file)
@@ -489,7 +489,7 @@ end_reason_to_http_connect_response_line(int endreason)
       return "HTTP/1.0 502 Bad Gateway (tor protocol violation)\r\n\r\n";
     case END_STREAM_REASON_ENTRYPOLICY:
       return "HTTP/1.0 403 Forbidden (entry policy violation)\r\n\r\n";
-    case END_STREAM_REASON_NOTDIRECTORY: /* Fall Through */
+    case END_STREAM_REASON_NOTDIRECTORY: FALLTHROUGH;
     default:
       tor_assert_nonfatal_unreached();
       return "HTTP/1.0 500 Internal Server Error (weird end reason)\r\n\r\n";
index a437b54792a0fe055c2d884835a4b026a98b11da..f83d2365e4f595232dfaef3a7b05c1ee6359bf8b 100644 (file)
@@ -940,7 +940,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. */
+        FALLTHROUGH;
       case END_STREAM_REASON_RESOLVEFAILED:
       case END_STREAM_REASON_TIMEOUT:
       case END_STREAM_REASON_MISC:
index 063342480a2009beacb3a5da1b225574b9d386b0..0e3f0fe815b94d680329209564714092aeaf2893 100644 (file)
@@ -192,7 +192,7 @@ get_scheduler_type_string(scheduler_types_t type)
   case SCHEDULER_KIST_LITE:
     return "KISTLite";
   case SCHEDULER_NONE:
-    /* fallthrough */
+    FALLTHROUGH;
   default:
     tor_assert_unreached();
     return "(N/A)";
@@ -288,7 +288,7 @@ select_scheduler(void)
       scheduler_kist_set_lite_mode();
       goto end;
     case SCHEDULER_NONE:
-      /* fallthrough */
+      FALLTHROUGH;
     default:
       /* Our option validation should have caught this. */
       tor_assert_unreached();
index 0757ce3d5294089aa143e83a0b57012cbd157da7..e61cf0c0f8f82c65688fb7be6383af9ce0b95a25 100644 (file)
@@ -293,7 +293,7 @@ send_circuit_level_sendme(circuit_t *circ, crypt_path_t *layer_hint,
     log_debug(LD_PROTOCOL, "Emitting SENDME version 1 cell.");
     break;
   case 0x00:
-    /* Fallthrough because default is to use v0. */
+    FALLTHROUGH;
   default:
     /* Unknown version, fallback to version 0 meaning no payload. */
     payload_len = 0;
index f9f8c8afc07c0759046354b22350756fd76571ba..c06e6b1a418f03847645a4a2837ca08513325417 100644 (file)
@@ -856,7 +856,7 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
       case SOCKS_RESULT_TRUNCATED:
         if (datalen == n_pullup)
           return 0;
-        /* FALLTHRU */
+        FALLTHROUGH;
       case SOCKS_RESULT_MORE_EXPECTED:
         res = 0;
         break;
@@ -962,7 +962,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
       strlcpy((char*)req->reply, SOCKS_PROXY_IS_NOT_AN_HTTP_PROXY_MSG,
               MAX_SOCKS_REPLY_LEN);
       req->replylen = strlen((char*)req->reply)+1;
-      /* fall through */
+      FALLTHROUGH;
     default: /* version is not socks4 or socks5 */
       log_warn(LD_APP,
                "Socks version %d not recognized. (This port is not an "
index faa52ae4e10001c29b2341e723cd50b7df26b1da..e0f5b2e5c9824a86e3dd61fbbed54f0defee5f16 100644 (file)
@@ -95,13 +95,13 @@ uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *k
        }
 #else
        switch (src_sz - blocks) {
-               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 7: last7 |= (uint64_t)m[i + 6] << 48; FALLTHROUGH;
+               case 6: last7 |= (uint64_t)m[i + 5] << 40; FALLTHROUGH;
+               case 5: last7 |= (uint64_t)m[i + 4] << 32; FALLTHROUGH;
+               case 4: last7 |= (uint64_t)m[i + 3] << 24; FALLTHROUGH;
+               case 3: last7 |= (uint64_t)m[i + 2] << 16; FALLTHROUGH;
+               case 2: last7 |= (uint64_t)m[i + 1] <<  8; FALLTHROUGH;
+               case 1: last7 |= (uint64_t)m[i + 0]      ; FALLTHROUGH;
                case 0:
                default:;
        }
index 0ef9e58fa16abe2d92f09fb48b307fe8b152823f..5934d9ca9d2a329d531f344bbe56cb2258ac3e5b 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++; /* 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 8: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 7: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 6: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 5: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 4: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
+               case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; FALLTHROUGH;
                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; /* 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 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1; FALLTHROUGH;
+               case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1; FALLTHROUGH;
+               case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1; FALLTHROUGH;
+               case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1; FALLTHROUGH;
+               case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1; FALLTHROUGH;
+               case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1; FALLTHROUGH;
+               case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1; FALLTHROUGH;
+               case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1; FALLTHROUGH;
                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; /* 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 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1; FALLTHROUGH;
+               case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1; FALLTHROUGH;
+               case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1; FALLTHROUGH;
+               case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1; FALLTHROUGH;
+               case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1; FALLTHROUGH;
+               case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1; FALLTHROUGH;
+               case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1; FALLTHROUGH;
+               case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1; FALLTHROUGH;
                case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
        }
        return 1;
index 06c98e30395142a8cd6708f740d5241d8dba40d6..aa361afdbc6f9611030dfa754b826ca71bed53d1 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++; /* 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 4: out[i] = (a[i] - b[i])        ; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; FALLTHROUGH;
+               case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; FALLTHROUGH;
+               case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; FALLTHROUGH;
+               case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; FALLTHROUGH;
                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++; /* 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 4: t = (a[i] - b[i])        ; carry = (t >> 63); i++; FALLTHROUGH;
+               case 3: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; FALLTHROUGH;
+               case 2: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; FALLTHROUGH;
+               case 1: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; FALLTHROUGH;
                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++; /* 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 4: t = (b[i] - a[i])        ; carry = (t >> 63); i++; FALLTHROUGH;
+               case 3: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; FALLTHROUGH;
+               case 2: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; FALLTHROUGH;
+               case 1: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; FALLTHROUGH;
                case 0: t = (b[i] - a[i]) - carry; carry = (t >> 63);
        }
        return (int)!carry;
index 36b575ef200e93e75f6b6b62a2941f10b9cb915c..537ead020b14a95672c033220f6c752b56e12311 100644 (file)
@@ -2263,7 +2263,7 @@ entry_guards_note_guard_success(guard_selection_t *gs,
       break;
     default:
       tor_assert_nonfatal_unreached();
-      /* Fall through. */
+      FALLTHROUGH;
     case GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD:
       if (guard->is_primary) {
         /* XXXX #20832 -- I don't actually like this logic. It seems to make
index de1bef7e5940b1459bcbc21d394dd5f46a7caeb3..68d05abb73976dc4000bc1b12ea67aa5d0034d0a 100644 (file)
@@ -1887,7 +1887,7 @@ handle_control_add_onion(control_connection_t *conn,
   case RSAE_BADAUTH:
     control_write_endreply(conn, 512, "Invalid client authorization");
     break;
-  case RSAE_INTERNAL: /* FALLSTHROUGH */
+  case RSAE_INTERNAL: FALLTHROUGH;
   default:
     control_write_endreply(conn, 551, "Failed to add Onion Service");
   }
index 1ea50fd35025e88029f5fe5dd793862735f16918..fa82bdc1e789f96dd3d8184c90e9f1767d20997a 100644 (file)
@@ -1369,7 +1369,7 @@ directory_initiate_request,(directory_request_t *request))
       case 1:
         /* start flushing conn */
         conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING;
-        /* fall through */
+        FALLTHROUGH;
       case 0:
         /* queue the command on the outbuf */
         directory_send_command(conn, 1, request);
index 6c2c4b06b79d3dd26b846016971bcca6bfbac5ad..c22ed186b8c42b4845f5e0baa33bd9a3746ff0ac 100644 (file)
@@ -222,7 +222,7 @@ token_check_object(memarea_t *area, const char *kwd,
                      kwd, crypto_pk_num_bits(tok->key));
         RET_ERR(ebuf);
       }
-      /* fall through */
+      FALLTHROUGH;
     case NEED_KEY: /* There must be some kind of key. */
       if (!tok->key) {
         tor_snprintf(ebuf, sizeof(ebuf), "Missing public key for %s", kwd);
index d9662962d2130a838c965387bde797e3466cee1a..d62598d46fa2336e59427cacb24326d29e55614e 100644 (file)
@@ -548,7 +548,7 @@ send_resolved_cell,(edge_connection_t *conn, uint8_t answer_type,
         answer_type = RESOLVED_TYPE_ERROR;
         /* We let this fall through and treat it as an error. */
       }
-      /* Falls through. */
+      FALLTHROUGH;
     case RESOLVED_TYPE_ERROR_TRANSIENT:
     case RESOLVED_TYPE_ERROR:
       {
index 2540066dfc4a78c936ea43768f5607be70f9cc3a..2e119d7c99a518d9a2b53d297f71145220229510 100644 (file)
@@ -831,7 +831,7 @@ rend_client_report_intro_point_failure(extend_info_t *failed_intro,
         log_warn(LD_BUG, "Unknown failure type %u. Removing intro point.",
                  failure_type);
         tor_fragile_assert();
-        /* fall through */
+        FALLTHROUGH;
       case INTRO_POINT_FAILURE_GENERIC:
         rend_cache_intro_failure_note(failure_type,
                                       (uint8_t *)failed_intro->identity_digest,
index bc7a0fab163e6aac661fcb24e325d3ada2d4d9c5..afa8f6d5efaf2f472439c89bececce89dc75cca4 100644 (file)
@@ -37,8 +37,8 @@ digest_alg_to_nss_oid(digest_algorithm_t alg)
     case DIGEST_SHA1: return SEC_OID_SHA1;
     case DIGEST_SHA256: return SEC_OID_SHA256;
     case DIGEST_SHA512: return SEC_OID_SHA512;
-    case DIGEST_SHA3_256: /* Fall through */
-    case DIGEST_SHA3_512: /* Fall through */
+    case DIGEST_SHA3_256: FALLTHROUGH;
+    case DIGEST_SHA3_512: FALLTHROUGH;
     default:
       return SEC_OID_UNKNOWN;
   }
@@ -85,12 +85,12 @@ static bool
 library_supports_digest(digest_algorithm_t alg)
 {
   switch (alg) {
-    case DIGEST_SHA1: /* Fall through */
-    case DIGEST_SHA256: /* Fall through */
+    case DIGEST_SHA1: FALLTHROUGH;
+    case DIGEST_SHA256: FALLTHROUGH;
     case DIGEST_SHA512:
       return true;
-    case DIGEST_SHA3_256: /* Fall through */
-    case DIGEST_SHA3_512: /* Fall through */
+    case DIGEST_SHA3_256: FALLTHROUGH;
+    case DIGEST_SHA3_512: FALLTHROUGH;
     default:
       return false;
   }
@@ -197,8 +197,8 @@ crypto_digest_alloc_bytes(digest_algorithm_t alg)
 #define END_OF_FIELD(f) (offsetof(crypto_digest_t, f) + \
                          STRUCT_FIELD_SIZE(crypto_digest_t, f))
   switch (alg) {
-    case DIGEST_SHA1: /* Fall through */
-    case DIGEST_SHA256: /* Fall through */
+    case DIGEST_SHA1: FALLTHROUGH;
+    case DIGEST_SHA256: FALLTHROUGH;
     case DIGEST_SHA512:
       return END_OF_FIELD(d.ctx);
     case DIGEST_SHA3_256:
@@ -224,8 +224,8 @@ crypto_digest_new_internal(digest_algorithm_t algorithm)
 
   switch (algorithm)
     {
-    case DIGEST_SHA1: /* fall through */
-    case DIGEST_SHA256: /* fall through */
+    case DIGEST_SHA1: FALLTHROUGH;
+    case DIGEST_SHA256: FALLTHROUGH;
     case DIGEST_SHA512:
       r->d.ctx = PK11_CreateDigestContext(digest_alg_to_nss_oid(algorithm));
       if (BUG(!r->d.ctx)) {
@@ -312,8 +312,8 @@ crypto_digest_add_bytes(crypto_digest_t *digest, const char *data,
    * just doing it ourselves. Hashes are fast.
    */
   switch (digest->algorithm) {
-    case DIGEST_SHA1: /* fall through */
-    case DIGEST_SHA256: /* fall through */
+    case DIGEST_SHA1: FALLTHROUGH;
+    case DIGEST_SHA256: FALLTHROUGH;
     case DIGEST_SHA512:
       tor_assert(len <= UINT_MAX);
       SECStatus s = PK11_DigestOp(digest->d.ctx,
@@ -321,7 +321,7 @@ crypto_digest_add_bytes(crypto_digest_t *digest, const char *data,
                                   (unsigned int)len);
       tor_assert(s == SECSuccess);
       break;
-    case DIGEST_SHA3_256: /* FALLSTHROUGH */
+    case DIGEST_SHA3_256: FALLTHROUGH;
     case DIGEST_SHA3_512:
       keccak_digest_update(&digest->d.sha3, (const uint8_t *)data, len);
       break;
index b0d8b6aee9da228cd1c81d7c7bc3bc8e3f1e1a57..50a8ff4d2795733d4e973b99dc02af9d4f1f01b6 100644 (file)
@@ -160,11 +160,11 @@ crypto_digest_alloc_bytes(digest_algorithm_t alg)
     case DIGEST_SHA512:
       return END_OF_FIELD(d.sha512);
 #ifdef OPENSSL_HAS_SHA3
-    case DIGEST_SHA3_256: /* Fall through */
+    case DIGEST_SHA3_256: FALLTHROUGH;
     case DIGEST_SHA3_512:
       return END_OF_FIELD(d.md);
 #else
-    case DIGEST_SHA3_256: /* Fall through */
+    case DIGEST_SHA3_256: FALLTHROUGH;
     case DIGEST_SHA3_512:
       return END_OF_FIELD(d.sha3);
 #endif /* defined(OPENSSL_HAS_SHA3) */
@@ -304,14 +304,14 @@ crypto_digest_add_bytes(crypto_digest_t *digest, const char *data,
       SHA512_Update(&digest->d.sha512, (void*)data, len);
       break;
 #ifdef OPENSSL_HAS_SHA3
-    case DIGEST_SHA3_256: /* FALLSTHROUGH */
+    case DIGEST_SHA3_256: FALLTHROUGH;
     case DIGEST_SHA3_512: {
       int r = EVP_DigestUpdate(digest->d.md, data, len);
       tor_assert(r);
   }
       break;
 #else /* !defined(OPENSSL_HAS_SHA3) */
-    case DIGEST_SHA3_256: /* FALLSTHROUGH */
+    case DIGEST_SHA3_256: FALLTHROUGH;
     case DIGEST_SHA3_512:
       keccak_digest_update(&digest->d.sha3, (const uint8_t *)data, len);
       break;
@@ -377,7 +377,7 @@ crypto_digest_get_digest(crypto_digest_t *digest,
       SHA512_Final(r, &tmpenv.d.sha512);
       break;
 //LCOV_EXCL_START
-    case DIGEST_SHA3_256: /* FALLSTHROUGH */
+    case DIGEST_SHA3_256: FALLTHROUGH;
     case DIGEST_SHA3_512:
     default:
       log_warn(LD_BUG, "Handling unexpected algorithm %d", digest->algorithm);
index a4a768ce84a7b3217723469b8456bc85144b3bce..6d3ebd23207d2b96563f922ec38ddf076450b580 100644 (file)
@@ -778,7 +778,7 @@ test_socks_truncated(void *ptr)
   for (i = 0; i < ARRAY_LENGTH(commands); ++i) {
     for (j = 0; j < commands[i].len; ++j) {
       switch (commands[i].setup) {
-        default: /* Falls through */
+        default: FALLTHROUGH;
         case NONE:
           /* This test calls for no setup on the socks state. */
           break;