Browse Source

Fix a huge pile of -Wshadow warnings.

These appeared on some of the Jenkins platforms. Apparently some
GCCs care when you shadow globals, and some don't.
Nick Mathewson 7 years ago
parent
commit
9fe6fea1cc

+ 8 - 8
src/common/compat.c

@@ -1181,10 +1181,10 @@ tor_open_socket,(int domain, int type, int protocol))
 
 /** Mockable wrapper for connect(). */
 MOCK_IMPL(tor_socket_t,
-tor_connect_socket,(tor_socket_t socket,const struct sockaddr *address,
+tor_connect_socket,(tor_socket_t sock, const struct sockaddr *address,
                      socklen_t address_len))
 {
-  return connect(socket,address,address_len);
+  return connect(sock,address,address_len);
 }
 
 /** As socket(), but creates a nonblocking socket and
@@ -1359,31 +1359,31 @@ get_n_open_sockets(void)
 
 /** Mockable wrapper for getsockname(). */
 MOCK_IMPL(int,
-tor_getsockname,(tor_socket_t socket, struct sockaddr *address,
+tor_getsockname,(tor_socket_t sock, struct sockaddr *address,
                  socklen_t *address_len))
 {
-   return getsockname(socket, address, address_len);
+   return getsockname(sock, address, address_len);
 }
 
 /** Turn <b>socket</b> into a nonblocking socket. Return 0 on success, -1
  * on failure.
  */
 int
-set_socket_nonblocking(tor_socket_t socket)
+set_socket_nonblocking(tor_socket_t sock)
 {
 #if defined(_WIN32)
   unsigned long nonblocking = 1;
-  ioctlsocket(socket, FIONBIO, (unsigned long*) &nonblocking);
+  ioctlsocket(sock, FIONBIO, (unsigned long*) &nonblocking);
 #else
   int flags;
 
-  flags = fcntl(socket, F_GETFL, 0);
+  flags = fcntl(sock, F_GETFL, 0);
   if (flags == -1) {
     log_warn(LD_NET, "Couldn't get file status flags: %s", strerror(errno));
     return -1;
   }
   flags |= O_NONBLOCK;
-  if (fcntl(socket, F_SETFL, flags) == -1) {
+  if (fcntl(sock, F_SETFL, flags) == -1) {
     log_warn(LD_NET, "Couldn't set file status flags: %s", strerror(errno));
     return -1;
   }

+ 3 - 3
src/common/crypto.c

@@ -3099,8 +3099,8 @@ crypto_rand_double(void)
 {
   /* We just use an unsigned int here; we don't really care about getting
    * more than 32 bits of resolution */
-  unsigned int uint;
-  crypto_rand((char*)&uint, sizeof(uint));
+  unsigned int u;
+  crypto_rand((char*)&u, sizeof(u));
 #if SIZEOF_INT == 4
 #define UINT_MAX_AS_DOUBLE 4294967296.0
 #elif SIZEOF_INT == 8
@@ -3108,7 +3108,7 @@ crypto_rand_double(void)
 #else
 #error SIZEOF_INT is neither 4 nor 8
 #endif
-  return ((double)uint) / UINT_MAX_AS_DOUBLE;
+  return ((double)u) / UINT_MAX_AS_DOUBLE;
 }
 
 /** Generate and return a new random hostname starting with <b>prefix</b>,

+ 2 - 2
src/common/log.c

@@ -1071,13 +1071,13 @@ mark_logs_temp(void)
  */
 int
 add_file_log(const log_severity_list_t *severity, const char *filename,
-             const int truncate)
+             const int truncate_log)
 {
   int fd;
   logfile_t *lf;
 
   int open_flags = O_WRONLY|O_CREAT;
-  open_flags |= truncate ? O_TRUNC : O_APPEND;
+  open_flags |= truncate_log ? O_TRUNC : O_APPEND;
 
   fd = tor_open_cloexec(filename, open_flags, 0644);
   if (fd<0)

+ 7 - 7
src/common/torgzip.c

@@ -418,13 +418,13 @@ struct tor_zlib_state_t {
  * <b>compress</b>, it's for compression; otherwise it's for
  * decompression. */
 tor_zlib_state_t *
-tor_zlib_new(int compress, compress_method_t method,
+tor_zlib_new(int compress_, compress_method_t method,
              zlib_compression_level_t compression_level)
 {
   tor_zlib_state_t *out;
   int bits, memlevel;
 
- if (! compress) {
+ if (! compress_) {
    /* use this setting for decompression, since we might have the
     * max number of window bits */
    compression_level = HIGH_COMPRESSION;
@@ -434,10 +434,10 @@ tor_zlib_new(int compress, compress_method_t method,
  out->stream.zalloc = Z_NULL;
  out->stream.zfree = Z_NULL;
  out->stream.opaque = NULL;
- out->compress = compress;
+ out->compress = compress_;
  bits = method_bits(method, compression_level);
  memlevel = get_memlevel(compression_level);
- if (compress) {
+ if (compress_) {
    if (deflateInit2(&out->stream, Z_BEST_COMPRESSION, Z_DEFLATED,
                     bits, memlevel,
                     Z_DEFAULT_STRATEGY) != Z_OK)
@@ -446,7 +446,7 @@ tor_zlib_new(int compress, compress_method_t method,
    if (inflateInit2(&out->stream, bits) != Z_OK)
      goto err; // LCOV_EXCL_LINE
  }
- out->allocation = tor_zlib_state_size_precalc(!compress, bits, memlevel);
+ out->allocation = tor_zlib_state_size_precalc(!compress_, bits, memlevel);
 
  total_zlib_allocation += out->allocation;
 
@@ -540,13 +540,13 @@ tor_zlib_free(tor_zlib_state_t *state)
 /** Return an approximate number of bytes used in RAM to hold a state with
  * window bits <b>windowBits</b> and compression level 'memlevel' */
 static size_t
-tor_zlib_state_size_precalc(int inflate, int windowbits, int memlevel)
+tor_zlib_state_size_precalc(int inflate_, int windowbits, int memlevel)
 {
   windowbits &= 15;
 
 #define A_FEW_KILOBYTES 2048
 
-  if (inflate) {
+  if (inflate_) {
     /* From zconf.h:
 
        "The memory requirements for inflate are (in bytes) 1 << windowBits

+ 33 - 32
src/common/util.c

@@ -305,17 +305,17 @@ tor_strdup_(const char *s DMALLOC_PARAMS)
 char *
 tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
 {
-  char *dup;
+  char *duplicate;
   tor_assert(s);
   tor_assert(n < SIZE_T_CEILING);
-  dup = tor_malloc_((n+1) DMALLOC_FN_ARGS);
+  duplicate = tor_malloc_((n+1) DMALLOC_FN_ARGS);
   /* Performance note: Ordinarily we prefer strlcpy to strncpy.  But
    * this function gets called a whole lot, and platform strncpy is
    * much faster than strlcpy when strlen(s) is much longer than n.
    */
-  strncpy(dup, s, n);
-  dup[n]='\0';
-  return dup;
+  strncpy(duplicate, s, n);
+  duplicate[n]='\0';
+  return duplicate;
 }
 
 /** Allocate a chunk of <b>len</b> bytes, with the same contents as the
@@ -323,12 +323,12 @@ tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
 void *
 tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS)
 {
-  char *dup;
+  char *duplicate;
   tor_assert(len < SIZE_T_CEILING);
   tor_assert(mem);
-  dup = tor_malloc_(len DMALLOC_FN_ARGS);
-  memcpy(dup, mem, len);
-  return dup;
+  duplicate = tor_malloc_(len DMALLOC_FN_ARGS);
+  memcpy(duplicate, mem, len);
+  return duplicate;
 }
 
 /** As tor_memdup(), but add an extra 0 byte at the end of the resulting
@@ -336,13 +336,13 @@ tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS)
 void *
 tor_memdup_nulterm_(const void *mem, size_t len DMALLOC_PARAMS)
 {
-  char *dup;
+  char *duplicate;
   tor_assert(len < SIZE_T_CEILING+1);
   tor_assert(mem);
-  dup = tor_malloc_(len+1 DMALLOC_FN_ARGS);
-  memcpy(dup, mem, len);
-  dup[len] = '\0';
-  return dup;
+  duplicate = tor_malloc_(len+1 DMALLOC_FN_ARGS);
+  memcpy(duplicate, mem, len);
+  duplicate[len] = '\0';
+  return duplicate;
 }
 
 /** Helper for places that need to take a function pointer to the right
@@ -556,7 +556,7 @@ sample_laplace_distribution(double mu, double b, double p)
  * The epsilon value must be between ]0.0, 1.0]. delta_f must be greater
  * than 0. */
 int64_t
-add_laplace_noise(int64_t signal, double random, double delta_f,
+add_laplace_noise(int64_t signal_, double random_, double delta_f,
                   double epsilon)
 {
   int64_t noise;
@@ -569,15 +569,15 @@ add_laplace_noise(int64_t signal, double random, double delta_f,
   /* Just add noise, no further signal */
   noise = sample_laplace_distribution(0.0,
                                       delta_f / epsilon,
-                                      random);
+                                      random_);
 
   /* Clip (signal + noise) to [INT64_MIN, INT64_MAX] */
-  if (noise > 0 && INT64_MAX - noise < signal)
+  if (noise > 0 && INT64_MAX - noise < signal_)
     return INT64_MAX;
-  else if (noise < 0 && INT64_MIN - noise > signal)
+  else if (noise < 0 && INT64_MIN - noise > signal_)
     return INT64_MIN;
   else
-    return signal + noise;
+    return signal_ + noise;
 }
 
 /* Helper: return greatest common divisor of a,b */
@@ -638,12 +638,12 @@ n_bits_set_u8(uint8_t v)
 void
 tor_strstrip(char *s, const char *strip)
 {
-  char *read = s;
-  while (*read) {
-    if (strchr(strip, *read)) {
-      ++read;
+  char *readp = s;
+  while (*readp) {
+    if (strchr(strip, *readp)) {
+      ++readp;
     } else {
-      *s++ = *read++;
+      *s++ = *readp++;
     }
   }
   *s = '\0';
@@ -1559,11 +1559,12 @@ tv_to_msec(const struct timeval *tv)
 #define IS_LEAPYEAR(y) (!(y % 4) && ((y % 100) || !(y % 400)))
 /** Helper: Return the number of leap-days between Jan 1, y1 and Jan 1, y2. */
 static int
-n_leapdays(int y1, int y2)
+n_leapdays(int year1, int year2)
 {
-  --y1;
-  --y2;
-  return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400);
+  --year1;
+  --year2;
+  return (year2/4 - year1/4) - (year2/100 - year1/100)
+    + (year2/400 - year1/400);
 }
 /** Number of days per month in non-leap year; used by tor_timegm and
  * parse_rfc1123_time. */
@@ -5688,7 +5689,7 @@ tor_weak_random_range(tor_weak_rng_t *rng, int32_t top)
 int64_t
 clamp_double_to_int64(double number)
 {
-  int exp;
+  int exponent;
 
   /* NaN is a special case that can't be used with the logic below. */
   if (isnan(number)) {
@@ -5702,14 +5703,14 @@ clamp_double_to_int64(double number)
    * magnitude of number is strictly less than 2^exp.
    *
    * If number is infinite, the call to frexp is legal but the contents of
-   * exp are unspecified. */
-  frexp(number, &exp);
+   * are exponent unspecified. */
+  frexp(number, &exponent);
 
   /* If the magnitude of number is strictly less than 2^63, the truncated
    * version of number is guaranteed to be representable. The only
    * representable integer for which this is not the case is INT64_MIN, but
    * it is covered by the logic below. */
-  if (isfinite(number) && exp <= 63) {
+  if (isfinite(number) && exponent <= 63) {
     return (int64_t)number;
   }
 

+ 3 - 3
src/ext/timeouts/timeout.c

@@ -299,9 +299,9 @@ TIMEOUT_PUBLIC void timeouts_del(struct timeouts *T, struct timeout *to) {
 		TOR_TAILQ_REMOVE(to->pending, to, tqe);
 
 		if (to->pending != &T->expired && TOR_TAILQ_EMPTY(to->pending)) {
-			ptrdiff_t index = to->pending - &T->wheel[0][0];
-			int wheel = (int) (index / WHEEL_LEN);
-			int slot = index % WHEEL_LEN;
+			ptrdiff_t index_ = to->pending - &T->wheel[0][0];
+			int wheel = (int) (index_ / WHEEL_LEN);
+			int slot = index_ % WHEEL_LEN;
 
 			T->pending[wheel] &= ~(WHEEL_C(1) << slot);
 		}

+ 12 - 12
src/or/addressmap.c

@@ -264,18 +264,18 @@ addressmap_clear_invalid_automaps(const or_options_t *options)
     clear_all = 1; /* This should be impossible, but let's be sure. */
 
   STRMAP_FOREACH_MODIFY(addressmap, src_address, addressmap_entry_t *, ent) {
-    int remove = clear_all;
+    int remove_this = clear_all;
     if (ent->source != ADDRMAPSRC_AUTOMAP)
       continue; /* not an automap mapping. */
 
-    if (!remove) {
-      remove = ! addressmap_address_should_automap(src_address, options);
+    if (!remove_this) {
+      remove_this = ! addressmap_address_should_automap(src_address, options);
     }
 
-    if (!remove && ! address_is_in_virtual_range(ent->new_address))
-      remove = 1;
+    if (!remove_this && ! address_is_in_virtual_range(ent->new_address))
+      remove_this = 1;
 
-    if (remove) {
+    if (remove_this) {
       addressmap_ent_remove(src_address, ent);
       MAP_DEL_CURRENT(src_address);
     }
@@ -896,10 +896,10 @@ addressmap_get_virtual_address(int type)
   tor_assert(addressmap);
 
   if (type == RESOLVED_TYPE_HOSTNAME) {
-    char rand[10];
+    char rand_bytes[10];
     do {
-      crypto_rand(rand, sizeof(rand));
-      base32_encode(buf,sizeof(buf),rand,sizeof(rand));
+      crypto_rand(rand_bytes, sizeof(rand_bytes));
+      base32_encode(buf,sizeof(buf),rand_bytes,sizeof(rand_bytes));
       strlcat(buf, ".virtual", sizeof(buf));
     } while (strmap_get(addressmap, buf));
     return tor_strdup(buf);
@@ -1107,11 +1107,11 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
              smartlist_add_asprintf(sl, "%s%s %s%s NEVER",
                                     src_wc, key, dst_wc, val->new_address);
            else {
-             char time[ISO_TIME_LEN+1];
-             format_iso_time(time, val->expires);
+             char isotime[ISO_TIME_LEN+1];
+             format_iso_time(isotime, val->expires);
              smartlist_add_asprintf(sl, "%s%s %s%s \"%s\"",
                                     src_wc, key, dst_wc, val->new_address,
-                                    time);
+                                    isotime);
            }
          } else {
            smartlist_add_asprintf(sl, "%s%s %s%s",

+ 21 - 21
src/or/circuitbuild.c

@@ -457,14 +457,14 @@ origin_circuit_init(uint8_t purpose, int flags)
  * it's not open already.
  */
 origin_circuit_t *
-circuit_establish_circuit(uint8_t purpose, extend_info_t *exit, int flags)
+circuit_establish_circuit(uint8_t purpose, extend_info_t *exit_ei, int flags)
 {
   origin_circuit_t *circ;
   int err_reason = 0;
 
   circ = origin_circuit_init(purpose, flags);
 
-  if (onion_pick_cpath_exit(circ, exit) < 0 ||
+  if (onion_pick_cpath_exit(circ, exit_ei) < 0 ||
       onion_populate_cpath(circ) < 0) {
     circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_NOPATH);
     return NULL;
@@ -1433,7 +1433,7 @@ onionskin_answer(or_circuit_t *circ,
  * to handle the desired path length, return -1.
  */
 static int
-new_route_len(uint8_t purpose, extend_info_t *exit, smartlist_t *nodes)
+new_route_len(uint8_t purpose, extend_info_t *exit_ei, smartlist_t *nodes)
 {
   int num_acceptable_routers;
   int routelen;
@@ -1441,7 +1441,7 @@ new_route_len(uint8_t purpose, extend_info_t *exit, smartlist_t *nodes)
   tor_assert(nodes);
 
   routelen = DEFAULT_ROUTE_LEN;
-  if (exit &&
+  if (exit_ei &&
       purpose != CIRCUIT_PURPOSE_TESTING &&
       purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)
     routelen++;
@@ -1957,7 +1957,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
  * router (or use <b>exit</b> if provided). Store these in the
  * cpath. Return 0 if ok, -1 if circuit should be closed. */
 static int
-onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
+onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
 {
   cpath_build_state_t *state = circ->build_state;
 
@@ -1965,17 +1965,17 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
     log_debug(LD_CIRC, "Launching a one-hop circuit for dir tunnel.");
     state->desired_path_len = 1;
   } else {
-    int r = new_route_len(circ->base_.purpose, exit, nodelist_get_list());
+    int r = new_route_len(circ->base_.purpose, exit_ei, nodelist_get_list());
     if (r < 1) /* must be at least 1 */
       return -1;
     state->desired_path_len = r;
   }
 
-  if (exit) { /* the circuit-builder pre-requested one */
-    warn_if_last_router_excluded(circ, exit);
+  if (exit_ei) { /* the circuit-builder pre-requested one */
+    warn_if_last_router_excluded(circ, exit_ei);
     log_info(LD_CIRC,"Using requested exit node '%s'",
-             extend_info_describe(exit));
-    exit = extend_info_dup(exit);
+             extend_info_describe(exit_ei));
+    exit_ei = extend_info_dup(exit_ei);
   } else { /* we have to decide one */
     const node_t *node =
       choose_good_exit_server(circ->base_.purpose, state->need_uptime,
@@ -1984,10 +1984,10 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
       log_warn(LD_CIRC,"Failed to choose an exit server");
       return -1;
     }
-    exit = extend_info_from_node(node, 0);
-    tor_assert(exit);
+    exit_ei = extend_info_from_node(node, 0);
+    tor_assert(exit_ei);
   }
-  state->chosen_exit = exit;
+  state->chosen_exit = exit_ei;
   return 0;
 }
 
@@ -1996,19 +1996,19 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
  * the caller will do this if it wants to.
  */
 int
-circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit)
+circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
 {
   cpath_build_state_t *state;
-  tor_assert(exit);
+  tor_assert(exit_ei);
   tor_assert(circ);
 
   state = circ->build_state;
   tor_assert(state);
   extend_info_free(state->chosen_exit);
-  state->chosen_exit = extend_info_dup(exit);
+  state->chosen_exit = extend_info_dup(exit_ei);
 
   ++circ->build_state->desired_path_len;
-  onion_append_hop(&circ->cpath, exit);
+  onion_append_hop(&circ->cpath, exit_ei);
   return 0;
 }
 
@@ -2017,18 +2017,18 @@ circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit)
  * send the next extend cell to begin connecting to that hop.
  */
 int
-circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit)
+circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
 {
   int err_reason = 0;
-  warn_if_last_router_excluded(circ, exit);
+  warn_if_last_router_excluded(circ, exit_ei);
 
   tor_gettimeofday(&circ->base_.timestamp_began);
 
-  circuit_append_new_exit(circ, exit);
+  circuit_append_new_exit(circ, exit_ei);
   circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
   if ((err_reason = circuit_send_next_onion_skin(circ))<0) {
     log_warn(LD_CIRC, "Couldn't extend circuit to new point %s.",
-             extend_info_describe(exit));
+             extend_info_describe(exit_ei));
     circuit_mark_for_close(TO_CIRCUIT(circ), -err_reason);
     return -1;
   }

+ 5 - 5
src/or/circuitstats.c

@@ -578,18 +578,18 @@ circuit_build_times_rewind_history(circuit_build_times_t *cbt, int n)
  * array is full.
  */
 int
-circuit_build_times_add_time(circuit_build_times_t *cbt, build_time_t time)
+circuit_build_times_add_time(circuit_build_times_t *cbt, build_time_t btime)
 {
-  if (time <= 0 || time > CBT_BUILD_TIME_MAX) {
+  if (btime <= 0 || btime > CBT_BUILD_TIME_MAX) {
     log_warn(LD_BUG, "Circuit build time is too large (%u)."
-                      "This is probably a bug.", time);
+                      "This is probably a bug.", btime);
     tor_fragile_assert();
     return -1;
   }
 
-  log_debug(LD_CIRC, "Adding circuit build time %u", time);
+  log_debug(LD_CIRC, "Adding circuit build time %u", btime);
 
-  cbt->circuit_build_times[cbt->build_times_idx] = time;
+  cbt->circuit_build_times[cbt->build_times_idx] = btime;
   cbt->build_times_idx = (cbt->build_times_idx + 1) % CBT_NCIRCUITS_TO_OBSERVE;
   if (cbt->total_build_times < CBT_NCIRCUITS_TO_OBSERVE)
     cbt->total_build_times++;

+ 6 - 6
src/or/config.c

@@ -5073,7 +5073,7 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
   config_line_t *opt;
   int ok;
   smartlist_t *elts;
-  int daemon =
+  int run_as_daemon =
 #ifdef _WIN32
                0;
 #else
@@ -5134,7 +5134,7 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
       int err = smartlist_len(elts) &&
         !strcasecmp(smartlist_get(elts,0), "stderr");
       if (!validate_only) {
-        if (daemon) {
+        if (run_as_daemon) {
           log_warn(LD_CONFIG,
                    "Can't log to %s with RunAsDaemon set; skipping stdout",
                    err?"stderr":"stdout");
@@ -5163,19 +5163,19 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
         char *fname = expand_filename(smartlist_get(elts, 1));
         /* Truncate if TruncateLogFile is set and we haven't seen this option
            line before. */
-        int truncate = 0;
+        int truncate_log = 0;
         if (options->TruncateLogFile) {
-          truncate = 1;
+          truncate_log = 1;
           if (old_options) {
             config_line_t *opt2;
             for (opt2 = old_options->Logs; opt2; opt2 = opt2->next)
               if (!strcmp(opt->value, opt2->value)) {
-                truncate = 0;
+                truncate_log = 0;
                 break;
               }
           }
         }
-        if (add_file_log(severity, fname, truncate) < 0) {
+        if (add_file_log(severity, fname, truncate_log) < 0) {
           log_warn(LD_CONFIG, "Couldn't open file for 'Log %s': %s",
                    opt->value, strerror(errno));
           ok = 0;

+ 9 - 7
src/or/connection_edge.c

@@ -3333,19 +3333,20 @@ connection_edge_is_rendezvous_stream(edge_connection_t *conn)
   return 0;
 }
 
-/** Return 1 if router <b>exit</b> is likely to allow stream <b>conn</b>
+/** Return 1 if router <b>exit_node</b> is likely to allow stream <b>conn</b>
  * to exit from it, or 0 if it probably will not allow it.
  * (We might be uncertain if conn's destination address has not yet been
  * resolved.)
  */
 int
-connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
+connection_ap_can_use_exit(const entry_connection_t *conn,
+                           const node_t *exit_node)
 {
   const or_options_t *options = get_options();
 
   tor_assert(conn);
   tor_assert(conn->socks_request);
-  tor_assert(exit);
+  tor_assert(exit_node);
 
   /* If a particular exit node has been requested for the new connection,
    * make sure the exit node of the existing circuit matches exactly.
@@ -3354,7 +3355,7 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
     const node_t *chosen_exit =
       node_get_by_nickname(conn->chosen_exit_name, 1);
     if (!chosen_exit || tor_memneq(chosen_exit->identity,
-                               exit->identity, DIGEST_LEN)) {
+                               exit_node->identity, DIGEST_LEN)) {
       /* doesn't match */
 //      log_debug(LD_APP,"Requested node '%s', considering node '%s'. No.",
 //                conn->chosen_exit_name, exit->nickname);
@@ -3379,7 +3380,8 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
       tor_addr_make_null(&addr, AF_INET);
       addrp = &addr;
     }
-    r = compare_tor_addr_to_node_policy(addrp, conn->socks_request->port,exit);
+    r = compare_tor_addr_to_node_policy(addrp, conn->socks_request->port,
+                                        exit_node);
     if (r == ADDR_POLICY_REJECTED)
       return 0; /* We know the address, and the exit policy rejects it. */
     if (r == ADDR_POLICY_PROBABLY_REJECTED && !conn->chosen_exit_name)
@@ -3388,10 +3390,10 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
                  * this node, err on the side of caution. */
   } else if (SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command)) {
     /* Don't send DNS requests to non-exit servers by default. */
-    if (!conn->chosen_exit_name && node_exit_policy_rejects_all(exit))
+    if (!conn->chosen_exit_name && node_exit_policy_rejects_all(exit_node))
       return 0;
   }
-  if (routerset_contains_node(options->ExcludeExitNodesUnion_, exit)) {
+  if (routerset_contains_node(options->ExcludeExitNodesUnion_, exit_node)) {
     /* Not a suitable exit. Refuse it. */
     return 0;
   }

+ 3 - 3
src/or/control.c

@@ -6084,14 +6084,14 @@ control_event_buildtimeout_set(buildtimeout_set_event_t type,
 
 /** Called when a signal has been processed from signal_callback */
 int
-control_event_signal(uintptr_t signal)
+control_event_signal(uintptr_t signal_num)
 {
   const char *signal_string = NULL;
 
   if (!control_event_is_interesting(EVENT_GOT_SIGNAL))
     return 0;
 
-  switch (signal) {
+  switch (signal_num) {
     case SIGHUP:
       signal_string = "RELOAD";
       break;
@@ -6112,7 +6112,7 @@ control_event_signal(uintptr_t signal)
       break;
     default:
       log_warn(LD_BUG, "Unrecognized signal %lu in control_event_signal",
-               (unsigned long)signal);
+               (unsigned long)signal_num);
       return -1;
   }
 

+ 0 - 3
src/or/dirvote.c

@@ -1431,7 +1431,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
 
   /* Add the actual router entries. */
   {
-    int *index; /* index[j] is the current index into votes[j]. */
     int *size; /* size[j] is the number of routerstatuses in votes[j]. */
     int *flag_counts; /* The number of voters that list flag[j] for the
                        * currently considered router. */
@@ -1466,7 +1465,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
     memset(conflict, 0, sizeof(conflict));
     memset(unknown, 0xff, sizeof(conflict));
 
-    index = tor_calloc(smartlist_len(votes), sizeof(int));
     size = tor_calloc(smartlist_len(votes), sizeof(int));
     n_voter_flags = tor_calloc(smartlist_len(votes), sizeof(int));
     n_flag_voters = tor_calloc(smartlist_len(flags), sizeof(int));
@@ -1932,7 +1930,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
       /* And the loop is over and we move on to the next router */
     }
 
-    tor_free(index);
     tor_free(size);
     tor_free(n_voter_flags);
     tor_free(n_flag_voters);

+ 4 - 4
src/or/policies.c

@@ -2669,7 +2669,7 @@ compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port,
 {
   int i;
   int found_match = 0;
-  int accept;
+  int accept_;
 
   tor_assert(port != 0);
 
@@ -2689,9 +2689,9 @@ compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port,
   }
 
   if (found_match)
-    accept = policy->is_accept;
+    accept_ = policy->is_accept;
   else
-    accept = ! policy->is_accept;
+    accept_ = ! policy->is_accept;
 
   /* ???? are these right? -NM */
   /* We should be sure not to return ADDR_POLICY_ACCEPTED in the accept
@@ -2704,7 +2704,7 @@ compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port,
    *
    * Once microdescriptors can handle addresses in special cases (e.g. if
    * we ever solve ticket 1774), we can provide certainty here. -RD */
-  if (accept)
+  if (accept_)
     return ADDR_POLICY_PROBABLY_ACCEPTED;
   else
     return ADDR_POLICY_REJECTED;

+ 4 - 4
src/or/relay.c

@@ -255,12 +255,12 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
     if (! CIRCUIT_IS_ORIGIN(circ) &&
         TO_OR_CIRCUIT(circ)->rend_splice &&
         cell_direction == CELL_DIRECTION_OUT) {
-      or_circuit_t *splice = TO_OR_CIRCUIT(circ)->rend_splice;
+      or_circuit_t *splice_ = TO_OR_CIRCUIT(circ)->rend_splice;
       tor_assert(circ->purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
-      tor_assert(splice->base_.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
-      cell->circ_id = splice->p_circ_id;
+      tor_assert(splice_->base_.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
+      cell->circ_id = splice_->p_circ_id;
       cell->command = CELL_RELAY; /* can't be relay_early anyway */
-      if ((reason = circuit_receive_relay_cell(cell, TO_CIRCUIT(splice),
+      if ((reason = circuit_receive_relay_cell(cell, TO_CIRCUIT(splice_),
                                                CELL_DIRECTION_IN)) < 0) {
         log_warn(LD_REND, "Error relaying cell across rendezvous; closing "
                  "circuits");

+ 3 - 3
src/or/rendclient.c

@@ -830,9 +830,9 @@ fetch_v2_desc_by_addr(rend_data_t *query, smartlist_t *hsdirs)
 
   tries_left = REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS;
   while (tries_left > 0) {
-    int rand = crypto_rand_int(tries_left);
-    int chosen_replica = replicas_left_to_try[rand];
-    replicas_left_to_try[rand] = replicas_left_to_try[--tries_left];
+    int rand_val = crypto_rand_int(tries_left);
+    int chosen_replica = replicas_left_to_try[rand_val];
+    replicas_left_to_try[rand_val] = replicas_left_to_try[--tries_left];
 
     ret = rend_compute_v2_desc_id(descriptor_id, query->onion_address,
                                   query->auth_type == REND_STEALTH_AUTH ?

+ 10 - 9
src/or/rephist.c

@@ -743,14 +743,15 @@ rep_history_clean(time_t before)
 
   orhist_it = digestmap_iter_init(history_map);
   while (!digestmap_iter_done(orhist_it)) {
-    int remove;
+    int should_remove;
     digestmap_iter_get(orhist_it, &d1, &or_history_p);
     or_history = or_history_p;
 
-    remove = authority ? (or_history->total_run_weights < STABILITY_EPSILON &&
+    should_remove = authority ?
+                       (or_history->total_run_weights < STABILITY_EPSILON &&
                           !or_history->start_of_run)
                        : (or_history->changed < before);
-    if (remove) {
+    if (should_remove) {
       orhist_it = digestmap_iter_next_rmv(history_map, orhist_it);
       free_or_history(or_history);
       continue;
@@ -2294,16 +2295,16 @@ void
 rep_hist_add_buffer_stats(double mean_num_cells_in_queue,
     double mean_time_cells_in_queue, uint32_t processed_cells)
 {
-  circ_buffer_stats_t *stat;
+  circ_buffer_stats_t *stats;
   if (!start_of_buffer_stats_interval)
     return; /* Not initialized. */
-  stat = tor_malloc_zero(sizeof(circ_buffer_stats_t));
-  stat->mean_num_cells_in_queue = mean_num_cells_in_queue;
-  stat->mean_time_cells_in_queue = mean_time_cells_in_queue;
-  stat->processed_cells = processed_cells;
+  stats = tor_malloc_zero(sizeof(circ_buffer_stats_t));
+  stats->mean_num_cells_in_queue = mean_num_cells_in_queue;
+  stats->mean_time_cells_in_queue = mean_time_cells_in_queue;
+  stats->processed_cells = processed_cells;
   if (!circuits_for_buffer_stats)
     circuits_for_buffer_stats = smartlist_new();
-  smartlist_add(circuits_for_buffer_stats, stat);
+  smartlist_add(circuits_for_buffer_stats, stats);
 }
 
 /** Remember cell statistics for circuit <b>circ</b> at time

+ 6 - 6
src/or/routerkeys.c

@@ -931,15 +931,15 @@ load_ed_keys(const or_options_t *options, time_t now)
 int
 generate_ed_link_cert(const or_options_t *options, time_t now)
 {
-  const tor_x509_cert_t *link = NULL, *id = NULL;
+  const tor_x509_cert_t *link_ = NULL, *id = NULL;
   tor_cert_t *link_cert = NULL;
 
-  if (tor_tls_get_my_certs(1, &link, &id) < 0 || link == NULL) {
+  if (tor_tls_get_my_certs(1, &link_, &id) < 0 || link_ == NULL) {
     log_warn(LD_OR, "Can't get my x509 link cert.");
     return -1;
   }
 
-  const common_digests_t *digests = tor_x509_cert_get_cert_digests(link);
+  const common_digests_t *digests = tor_x509_cert_get_cert_digests(link_);
 
   if (link_cert_cert &&
       ! EXPIRES_SOON(link_cert_cert, options->TestingLinkKeySlop) &&
@@ -979,12 +979,12 @@ should_make_new_ed_keys(const or_options_t *options, const time_t now)
       EXPIRES_SOON(link_cert_cert, options->TestingLinkKeySlop))
     return 1;
 
-  const tor_x509_cert_t *link = NULL, *id = NULL;
+  const tor_x509_cert_t *link_ = NULL, *id = NULL;
 
-  if (tor_tls_get_my_certs(1, &link, &id) < 0 || link == NULL)
+  if (tor_tls_get_my_certs(1, &link_, &id) < 0 || link_ == NULL)
     return 1;
 
-  const common_digests_t *digests = tor_x509_cert_get_cert_digests(link);
+  const common_digests_t *digests = tor_x509_cert_get_cert_digests(link_);
 
   if (!fast_memeq(digests->d[DIGEST_SHA256],
                   link_cert_cert->signed_key.pubkey,

+ 5 - 5
src/or/shared_random.c

@@ -115,16 +115,16 @@ static int32_t num_srv_agreements_from_vote;
 STATIC sr_srv_t *
 srv_dup(const sr_srv_t *orig)
 {
-  sr_srv_t *dup = NULL;
+  sr_srv_t *duplicate = NULL;
 
   if (!orig) {
     return NULL;
   }
 
-  dup = tor_malloc_zero(sizeof(sr_srv_t));
-  dup->num_reveals = orig->num_reveals;
-  memcpy(dup->value, orig->value, sizeof(dup->value));
-  return dup;
+  duplicate = tor_malloc_zero(sizeof(sr_srv_t));
+  duplicate->num_reveals = orig->num_reveals;
+  memcpy(duplicate->value, orig->value, sizeof(duplicate->value));
+  return duplicate;
 }
 
 /* Allocate a new commit object and initializing it with <b>rsa_identity</b>

+ 4 - 4
src/test/test_address.c

@@ -562,13 +562,13 @@ static int last_connected_socket_fd = 0;
 static int connect_retval = 0;
 
 static tor_socket_t
-pretend_to_connect(tor_socket_t socket, const struct sockaddr *address,
+pretend_to_connect(tor_socket_t sock, const struct sockaddr *address,
                    socklen_t address_len)
 {
   (void)address;
   (void)address_len;
 
-  last_connected_socket_fd = socket;
+  last_connected_socket_fd = sock;
 
   return connect_retval;
 }
@@ -576,11 +576,11 @@ pretend_to_connect(tor_socket_t socket, const struct sockaddr *address,
 static struct sockaddr *mock_addr = NULL;
 
 static int
-fake_getsockname(tor_socket_t socket, struct sockaddr *address,
+fake_getsockname(tor_socket_t sock, struct sockaddr *address,
                  socklen_t *address_len)
 {
   socklen_t bytes_to_copy = 0;
-  (void) socket;
+  (void) sock;
 
   if (!mock_addr)
     return -1;

+ 3 - 3
src/test/test_util.c

@@ -5240,12 +5240,12 @@ test_util_pwdb(void *arg)
   tt_assert(dir != NULL);
 
   /* Try failing cases.  First find a user that doesn't exist by name */
-  char rand[4];
+  char randbytes[4];
   char badname[9];
   int i, found=0;
   for (i = 0; i < 100; ++i) {
-    crypto_rand(rand, sizeof(rand));
-    base16_encode(badname, sizeof(badname), rand, sizeof(rand));
+    crypto_rand(randbytes, sizeof(randbytes));
+    base16_encode(badname, sizeof(badname), randbytes, sizeof(randbytes));
     if (tor_getpwnam(badname) == NULL) {
       found = 1;
       break;