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

Fix all -Wshadow warnings on Linux

This is a partial fix for 18902.
parent 1135405c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1821,6 +1821,7 @@ if test "x$enable_gcc_warnings_advisory" != "xno"; then
     -Wselector-type-mismatch
     -Wsentinel
     -Wserialized-diagnostics
     -Wshadow
     -Wshift-count-negative
     -Wshift-count-overflow
     -Wshift-negative-value
+2 −2
Original line number Diff line number Diff line
@@ -3812,9 +3812,9 @@ format_win_cmdline_argument(const char *arg)
    formatted_arg[i++] = '"';

  /* Add characters */
  SMARTLIST_FOREACH(arg_chars, char*, c,
  SMARTLIST_FOREACH(arg_chars, char*, ch,
  {
    formatted_arg[i++] = *c;
    formatted_arg[i++] = *ch;
  });

  /* Add trailing quote */
+2 −2
Original line number Diff line number Diff line
@@ -1901,8 +1901,8 @@ channel_tls_process_certs_cell(var_cell_t *cell, channel_tls_t *chan)
  }

 err:
  for (unsigned i = 0; i < ARRAY_LENGTH(certs); ++i) {
    tor_x509_cert_free(certs[i]);
  for (unsigned u = 0; u < ARRAY_LENGTH(certs); ++u) {
    tor_x509_cert_free(certs[u]);
  }
  certs_cell_free(cc);
#undef ERR
+7 −7
Original line number Diff line number Diff line
@@ -1565,7 +1565,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
  int n_best_support=0;
  const or_options_t *options = get_options();
  const smartlist_t *the_nodes;
  const node_t *node=NULL;
  const node_t *selected_node=NULL;

  connections = get_connection_array();

@@ -1692,7 +1692,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
        smartlist_add(supporting, (void*)node);
    });

    node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
    selected_node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
    smartlist_free(supporting);
  } else {
    /* Either there are no pending connections, or no routers even seem to
@@ -1730,8 +1730,8 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
        }
      } SMARTLIST_FOREACH_END(node);

      node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
      if (node)
      selected_node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
      if (selected_node)
        break;
      smartlist_clear(supporting);
      /* If we reach this point, we can't actually support any unhandled
@@ -1745,9 +1745,9 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
  }

  tor_free(n_supported);
  if (node) {
    log_info(LD_CIRC, "Chose exit server '%s'", node_describe(node));
    return node;
  if (selected_node) {
    log_info(LD_CIRC, "Chose exit server '%s'", node_describe(selected_node));
    return selected_node;
  }
  if (options->ExitNodes) {
    log_warn(LD_CIRC,
+14 −16
Original line number Diff line number Diff line
@@ -3488,10 +3488,10 @@ options_validate(or_options_t *old_options, or_options_t *options,
  }

  if (server_mode(options)) {
    char *msg = NULL;
    if (have_enough_mem_for_dircache(options, 0, &msg)) {
      log_warn(LD_CONFIG, "%s", msg);
      tor_free(msg);
    char *dircache_msg = NULL;
    if (have_enough_mem_for_dircache(options, 0, &dircache_msg)) {
      log_warn(LD_CONFIG, "%s", dircache_msg);
      tor_free(dircache_msg);
    }
  }

@@ -4820,7 +4820,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
{
  or_options_t *oldoptions, *newoptions, *newdefaultoptions=NULL;
  config_line_t *cl;
  int retval, i;
  int retval;
  setopt_err_t err = SETOPT_ERR_MISC;
  tor_assert(msg);

@@ -4833,7 +4833,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
  newoptions->command = command;
  newoptions->command_arg = command_arg ? tor_strdup(command_arg) : NULL;

  for (i = 0; i < 2; ++i) {
  for (int i = 0; i < 2; ++i) {
    const char *body = i==0 ? cf_defaults : cf;
    if (!body)
      continue;
@@ -4877,8 +4877,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
     * let's clean it up.  -NM */

    /* Change defaults. */
    int i;
    for (i = 0; testing_tor_network_defaults[i].name; ++i) {
    for (int i = 0; testing_tor_network_defaults[i].name; ++i) {
      const config_var_t *new_var = &testing_tor_network_defaults[i];
      config_var_t *old_var =
          config_find_option_mutable(&options_format, new_var->name);
@@ -4898,7 +4897,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
    newoptions->command_arg = command_arg ? tor_strdup(command_arg) : NULL;

    /* Assign all options a second time. */
    for (i = 0; i < 2; ++i) {
    for (int i = 0; i < 2; ++i) {
      const char *body = i==0 ? cf_defaults : cf;
      if (!body)
        continue;
@@ -5914,10 +5913,10 @@ parse_dir_fallback_line(const char *line,
        ipv6_addrport_ptr = &ipv6_addrport;
      }
    } else if (!strcmpstart(cp, "weight=")) {
      int ok;
      int num_ok;
      const char *wstring = cp + strlen("weight=");
      weight = tor_parse_double(wstring, 0, (double)UINT64_MAX, &ok, NULL);
      if (!ok) {
      weight = tor_parse_double(wstring, 0, (double)UINT64_MAX, &num_ok, NULL);
      if (!num_ok) {
        log_warn(LD_CONFIG, "Invalid weight '%s' on FallbackDir line.", cp);
        weight=1.0;
      }
@@ -7409,8 +7408,8 @@ getinfo_helper_config(control_connection_t *conn,
    smartlist_free(sl);
  } else if (!strcmp(question, "config/defaults")) {
    smartlist_t *sl = smartlist_new();
    int i, dirauth_lines_seen = 0, fallback_lines_seen = 0;
    for (i = 0; option_vars_[i].name; ++i) {
    int dirauth_lines_seen = 0, fallback_lines_seen = 0;
    for (int i = 0; option_vars_[i].name; ++i) {
      const config_var_t *var = &option_vars_[i];
      if (var->initvalue != NULL) {
        if (strcmp(option_vars_[i].name, "DirAuthority") == 0) {
@@ -7438,14 +7437,13 @@ getinfo_helper_config(control_connection_t *conn,
       * We didn't see any directory authorities with default values,
       * so add the list of default authorities manually.
       */
      const char **i;

      /*
       * default_authorities is defined earlier in this file and
       * is a const char ** NULL-terminated array of dirauth config
       * lines.
       */
      for (i = default_authorities; *i != NULL; ++i) {
      for (const char **i = default_authorities; *i != NULL; ++i) {
        char *val = esc_for_log(*i);
        smartlist_add_asprintf(sl, "DirAuthority %s\n", val);
        tor_free(val);
Loading