diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-05-06 10:45:48 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-05-06 16:53:40 -0400 |
commit | 28ac17f433d954355494989983005498c7fe9292 (patch) | |
tree | 67d3313f95eaa7630cfd055b5f5f0b2933cf6d99 /src/core | |
parent | f954514b376e6edbe8b1faba0726bdb46acf7729 (diff) | |
download | tor-28ac17f433d954355494989983005498c7fe9292.tar.gz tor-28ac17f433d954355494989983005498c7fe9292.zip |
Use __attribute__((fallthrough)) rather than magic GCC comments.
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.)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/channeltls.c | 2 | ||||
-rw-r--r-- | src/core/or/circuitbuild.c | 2 | ||||
-rw-r--r-- | src/core/or/circuitlist.c | 2 | ||||
-rw-r--r-- | src/core/or/circuituse.c | 2 | ||||
-rw-r--r-- | src/core/or/connection_edge.c | 6 | ||||
-rw-r--r-- | src/core/or/crypt_path.c | 2 | ||||
-rw-r--r-- | src/core/or/onion.c | 2 | ||||
-rw-r--r-- | src/core/or/policies.c | 2 | ||||
-rw-r--r-- | src/core/or/reasons.c | 2 | ||||
-rw-r--r-- | src/core/or/relay.c | 2 | ||||
-rw-r--r-- | src/core/or/scheduler.c | 4 | ||||
-rw-r--r-- | src/core/or/sendme.c | 2 | ||||
-rw-r--r-- | src/core/proto/proto_socks.c | 4 |
13 files changed, 17 insertions, 17 deletions
diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c index e9497651ef..d6c9e21631 100644 --- a/src/core/or/channeltls.c +++ b/src/core/or/channeltls.c @@ -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, diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c index 1daf468715..16bb7e7d79 100644 --- a/src/core/or/circuitbuild.c +++ b/src/core/or/circuitbuild.c @@ -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); diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c index 9ee9f93c99..61bcfa9039 100644 --- a/src/core/or/circuitlist.c +++ b/src/core/or/circuitlist.c @@ -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: diff --git a/src/core/or/circuituse.c b/src/core/or/circuituse.c index 606c5e2dd2..284e315f9c 100644 --- a/src/core/or/circuituse.c +++ b/src/core/or/circuituse.c @@ -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. */ diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 5f1664d286..4f5f038e6c 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -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; diff --git a/src/core/or/crypt_path.c b/src/core/or/crypt_path.c index 6d5245510f..9b7efc28bf 100644 --- a/src/core/or/crypt_path.c +++ b/src/core/or/crypt_path.c @@ -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); diff --git a/src/core/or/onion.c b/src/core/or/onion.c index aa77465b96..aeddedd807 100644 --- a/src/core/or/onion.c +++ b/src/core/or/onion.c @@ -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); diff --git a/src/core/or/policies.c b/src/core/or/policies.c index 83d9a53fc0..39a0817c85 100644 --- a/src/core/or/policies.c +++ b/src/core/or/policies.c @@ -2842,7 +2842,7 @@ parse_short_policy(const char *summary) switch (*next) { case ',': ++next; - /* fall through */ + FALLTHROUGH; case '\0': high = low; break; diff --git a/src/core/or/reasons.c b/src/core/or/reasons.c index a7952279ba..e21bfa670a 100644 --- a/src/core/or/reasons.c +++ b/src/core/or/reasons.c @@ -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"; diff --git a/src/core/or/relay.c b/src/core/or/relay.c index a437b54792..f83d2365e4 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -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: diff --git a/src/core/or/scheduler.c b/src/core/or/scheduler.c index 063342480a..0e3f0fe815 100644 --- a/src/core/or/scheduler.c +++ b/src/core/or/scheduler.c @@ -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(); diff --git a/src/core/or/sendme.c b/src/core/or/sendme.c index 0757ce3d52..e61cf0c0f8 100644 --- a/src/core/or/sendme.c +++ b/src/core/or/sendme.c @@ -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; diff --git a/src/core/proto/proto_socks.c b/src/core/proto/proto_socks.c index f9f8c8afc0..c06e6b1a41 100644 --- a/src/core/proto/proto_socks.c +++ b/src/core/proto/proto_socks.c @@ -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 " |