Commit cc397449 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

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;
parent 78a72f81
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ config_assign_value(const config_format_t *fmt, void *options,
      *(int *)lvalue = CFG_AUTO_PORT;
      break;
    }
    /* fall through */
    FALLTHROUGH;
  case CONFIG_TYPE_INT:
  case CONFIG_TYPE_UINT:
    i = (int)tor_parse_long(c->value, 10,
@@ -577,7 +577,7 @@ config_get_assigned_option(const config_format_t *fmt, const void *options,
        escape_val = 0;
        break;
      }
      /* fall through */
      FALLTHROUGH;
    case CONFIG_TYPE_CSV_INTERVAL:
    case CONFIG_TYPE_INTERVAL:
    case CONFIG_TYPE_MSEC_INTERVAL:
@@ -588,7 +588,7 @@ config_get_assigned_option(const config_format_t *fmt, const void *options,
      tor_asprintf(&result->value, "%d", *(int*)value);
      escape_val = 0; /* Can't need escape. */
      break;
    case CONFIG_TYPE_UINT64: /* Fall through */
    case CONFIG_TYPE_UINT64: FALLTHROUGH;
    case CONFIG_TYPE_MEMUNIT:
      tor_asprintf(&result->value, "%"PRIu64,
                   (*(uint64_t*)value));
@@ -605,7 +605,7 @@ config_get_assigned_option(const config_format_t *fmt, const void *options,
        escape_val = 0;
        break;
      }
      /* fall through */
      FALLTHROUGH;
    case CONFIG_TYPE_BOOL:
      result->value = tor_strdup(*(int*)value ? "1" : "0");
      escape_val = 0; /* Can't need escape. */
+1 −1
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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. */
Loading