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;
This commit is contained in:
Nick Mathewson
2020-05-06 10:45:48 -04:00
parent 78a72f8196
commit cc397449fc
22 changed files with 81 additions and 81 deletions
+1 -1
View File
@@ -1238,7 +1238,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,
+1 -1
View File
@@ -2106,7 +2106,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);
+2 -2
View File
@@ -787,7 +787,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:
@@ -2738,7 +2738,7 @@ assert_cpath_layer_ok(const crypt_path_t *cp)
{
case CPATH_STATE_OPEN:
relay_crypto_assert_ok(&cp->crypto);
/* fall through */
FALLTHROUGH;
case CPATH_STATE_CLOSED:
/*XXXX Assert that there's no handshake_state either. */
tor_assert(!cp->rend_dh_handshake_state);
+1 -1
View File
@@ -780,7 +780,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. */
+1 -1
View File
@@ -324,7 +324,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:
+1 -1
View 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);
+1 -1
View 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";
+1 -1
View File
@@ -866,7 +866,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:
+2 -2
View 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();
+2 -2
View 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 "