Browse Source

r15512@catbus: nickm | 2007-10-02 16:27:43 -0400
Make some functions static; remove some dead code.


svn:r11750

Nick Mathewson 16 years ago
parent
commit
8439c4ec2f
7 changed files with 22 additions and 78 deletions
  1. 3 0
      ChangeLog
  2. 0 34
      src/common/aes.c
  3. 5 3
      src/or/config.c
  4. 2 0
      src/or/connection.c
  5. 2 1
      src/or/connection_edge.c
  6. 8 32
      src/or/dirvote.c
  7. 2 8
      src/or/or.h

+ 3 - 0
ChangeLog

@@ -37,6 +37,9 @@ Changes in version 0.2.0.8-alpha - 2007-??-??
       advantage of 64-bit platforms and to remove some possibly-costly
       voodoo.
 
+  o Code simplifications and refactoring:
+    - Make a bunch of functions static.  Remove some dead code.
+
 
 Changes in version 0.2.0.7-alpha - 2007-09-21
   o New directory authorities:

+ 0 - 34
src/common/aes.c

@@ -311,29 +311,6 @@ aes_crypt(aes_cnt_cipher_t *cipher, const char *input, size_t len,
   }
 }
 
-#if 0
-/** Return the current value of <b>cipher</b>'s counter. */
-u64
-aes_get_counter(aes_cnt_cipher_t *cipher)
-{
-  u64 counter = cipher->pos;
-  counter |= ((u64)cipher->counter0) << 4;
-  counter |= ((u64)cipher->counter1) << 36;
-  return counter;
-}
-
-/** Set <b>cipher</b>'s counter to <b>counter</b>. */
-void
-aes_set_counter(aes_cnt_cipher_t *cipher, u64 counter)
-{
-  cipher->pos = (u8)(counter & 0x0f);
-  cipher->counter0 = (u32) ((counter >> 4) & 0xffffffff);
-  cipher->counter1 = (u32) (counter >> 36);
-
-  _aes_fill_buf(cipher);
-}
-#endif
-
 /** DOCDOC */
 void
 aes_set_iv(aes_cnt_cipher_t *cipher, const char *iv)
@@ -352,17 +329,6 @@ aes_set_iv(aes_cnt_cipher_t *cipher, const char *iv)
   _aes_fill_buf(cipher);
 }
 
-#if 0
-/** Increment <b>cipher</b>'s counter by <b>delta</b>. */
-void
-aes_adjust_counter(aes_cnt_cipher_t *cipher, long delta)
-{
-  u64 counter = aes_get_counter(cipher);
-  counter += delta;
-  aes_set_counter(cipher, counter);
-}
-#endif
-
 #ifdef USE_BUILTIN_AES
 /*======================================================================*/
 /* From rijndael-alg-fst.c */

+ 5 - 3
src/or/config.c

@@ -611,6 +611,8 @@ static config_line_t *get_assigned_option(config_format_t *fmt,
 static void config_init(config_format_t *fmt, void *options);
 static int or_state_validate(or_state_t *old_options, or_state_t *options,
                              int from_setconf, char **msg);
+static int or_state_load(void);
+static int options_init_logs(or_options_t *options, int validate_only);
 
 static uint64_t config_parse_memunit(const char *s, int *ok);
 static int config_parse_interval(const char *s, int *ok);
@@ -2331,7 +2333,7 @@ config_dump(config_format_t *fmt, void *options, int minimal,
  * the configuration in <b>options</b>.  If <b>minimal</b> is true, do not
  * include options that are the same as Tor's defaults.
  */
-char *
+static char *
 options_dump(or_options_t *options, int minimal)
 {
   return config_dump(&options_format, options, minimal, 0);
@@ -3515,7 +3517,7 @@ parse_log_severity_range(const char *range, int *min_out, int *max_out)
 /**
  * Initialize the logs based on the configuration file.
  */
-int
+static int
 options_init_logs(or_options_t *options, int validate_only)
 {
   config_line_t *opt;
@@ -4366,7 +4368,7 @@ or_state_set(or_state_t *new_state)
 /** Reload the persistent state from disk, generating a new state as needed.
  * Return 0 on success, less than 0 on failure.
  */
-int
+static int
 or_state_load(void)
 {
   or_state_t *new_state = NULL;

+ 2 - 0
src/or/connection.c

@@ -2369,6 +2369,7 @@ connection_get_by_type_state(int type, int state)
   return NULL;
 }
 
+#if 0
 /** Return the connection of type <b>type</b> that is in state
  * <b>state</b>, that was written to least recently, and that is not
  * marked for close.
@@ -2386,6 +2387,7 @@ connection_get_by_type_state_lastwritten(int type, int state)
   });
   return best;
 }
+#endif
 
 /** Return a connection of type <b>type</b> that has rendquery equal
  * to <b>rendquery</b>, and that is not marked for close. If state

+ 2 - 1
src/or/connection_edge.c

@@ -30,6 +30,7 @@ static smartlist_t *redirect_exit_list = NULL;
 static int connection_ap_handshake_process_socks(edge_connection_t *conn);
 static int connection_ap_process_natd(edge_connection_t *conn);
 static int connection_exit_connect_dir(edge_connection_t *exitconn);
+static int address_is_in_virtual_range(const char *addr);
 
 /** An AP stream has failed/finished. If it hasn't already sent back
  * a socks reply, send one now (based on endreason). Also set
@@ -967,7 +968,7 @@ parse_virtual_addr_network(const char *val, int validate_only,
  * Return true iff <b>addr</b> is likely to have been returned by
  * client_dns_get_unused_address.
  **/
-int
+static int
 address_is_in_virtual_range(const char *address)
 {
   struct in_addr in;

+ 8 - 32
src/or/dirvote.c

@@ -19,8 +19,10 @@ static int dirvote_add_signatures_to_pending_consensus(
 static char *list_v3_auth_ids(void);
 static void dirvote_fetch_missing_votes(void);
 static void dirvote_fetch_missing_signatures(void);
-
-/* XXXX020 lots of the functions here could be made static. Do so. */
+static void dirvote_perform_vote(void);
+static void dirvote_clear_votes(int all_votes);
+static int dirvote_compute_consensus(void);
+static int dirvote_publish_consensus(void);
 
 /* =====
  * Voting and consensus generation
@@ -858,30 +860,6 @@ networkstatus_add_signatures_impl(networkstatus_vote_t *target,
   return r;
 }
 
-#if 0
-/** As networkstatus_add_consensus_signature_impl, but takes new signatures
- * from the consensus in <b>src</b>. */
-int
-networkstatus_add_consensus_signatures(networkstatus_vote_t *target,
-                                       networkstatus_vote_t *src,
-                                       char **new_signatures_out)
-{
-  tor_assert(src);
-  tor_assert(! src->is_vote);
-
-  *new_signatures_out = NULL;
-
-  /* Are they the same consensus? */
-  if (memcmp(target->networkstatus_digest, src->networkstatus_digest,
-             DIGEST_LEN))
-    return -1;
-  if (target == src)
-    return 0;
-
-  return networkstatus_add_signatures_impl(target, src->voters);
-}
-#endif
-
 /** As networkstatus_add_consensus_signature_impl, but takes new signatures
  * from the detached signatures document <b>sigs</b>. */
 int
@@ -1217,7 +1195,7 @@ static smartlist_t *pending_consensus_signature_list = NULL;
 
 /** Generate a networkstatus vote and post it to all the v3 authorities.
  * (V3 Authority only) */
-void
+static void
 dirvote_perform_vote(void)
 {
   cached_dir_t *new_vote = generate_v3_networkstatus();
@@ -1290,7 +1268,7 @@ dirvote_fetch_missing_signatures(void)
 }
 
 /** Drop all currently pending votes, consensus, and detached signatures. */
-void
+static void
 dirvote_clear_votes(int all_votes)
 {
   if (!previous_vote_list)
@@ -1490,7 +1468,7 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
  * votes.  Return 0 on success, -1 on failure.  Store the consensus in
  * pending_consensus: it won't be ready to be published until we have
  * everybody else's signatures collected too. (V3 Authoritity only) */
-int
+static int
 dirvote_compute_consensus(void)
 {
   /* Have we got enough votes to try? */
@@ -1616,8 +1594,6 @@ dirvote_add_signatures_to_pending_consensus(
   r = networkstatus_add_detached_signatures(pending_consensus,
                                             sigs);
 
-  // XXXX020 originally, this test was regenerate && r >= 0).  But one
-  // code path is simpler than 2.
   if (r >= 0) {
     /* XXXX This should really be its own function. */
     char *new_detached =
@@ -1685,7 +1661,7 @@ dirvote_add_signatures(const char *detached_signatures_body)
 
 /** Replace the consensus that we're currently serving with the one that we've
  * been building. (V3 Authority only) */
-int
+static int
 dirvote_publish_consensus(void)
 {
   /* Can we actually publish it yet? */

+ 2 - 8
src/or/or.h

@@ -2412,17 +2412,14 @@ int resolve_my_address(int warn_severity, or_options_t *options,
 int is_local_IP(uint32_t ip) ATTR_PURE;
 void options_init(or_options_t *options);
 int options_init_from_torrc(int argc, char **argv);
-int options_init_logs(or_options_t *options, int validate_only);
 int option_is_recognized(const char *key);
 const char *option_get_canonical_name(const char *key);
 config_line_t *option_get_assignment(or_options_t *options,
                                      const char *key);
-char *options_dump(or_options_t *options, int minimal);
 int options_save_current(void);
 const char *get_torrc_fname(void);
 
 or_state_t *get_or_state(void);
-int or_state_load(void);
 int or_state_save(time_t now);
 
 int getinfo_helper_config(control_connection_t *conn,
@@ -2496,7 +2493,9 @@ connection_t *connection_get_by_type_purpose(int type, int purpose);
 connection_t *connection_get_by_type_addr_port_purpose(int type, uint32_t addr,
                                                    uint16_t port, int purpose);
 connection_t *connection_get_by_type_state(int type, int state);
+#if 0
 connection_t *connection_get_by_type_state_lastwritten(int type, int state);
+#endif
 connection_t *connection_get_by_type_state_rendquery(int type, int state,
                                                      const char *rendquery);
 
@@ -2572,7 +2571,6 @@ int client_dns_incr_failures(const char *address);
 void client_dns_clear_failures(const char *address);
 void client_dns_set_addressmap(const char *address, uint32_t val,
                                const char *exitname, int ttl);
-int address_is_in_virtual_range(const char *addr);
 const char *addressmap_register_virtual_address(int type, char *new_address);
 void addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
                              time_t max_expires, int want_expiry);
@@ -2886,14 +2884,10 @@ void dirvote_recalculate_timing(time_t now);
 void dirvote_act(time_t now);
 
 /* invoked on timers and by outside triggers. */
-void dirvote_perform_vote(void);
-void dirvote_clear_votes(int all_votes);
 struct pending_vote_t * dirvote_add_vote(const char *vote_body,
                                          const char **msg_out,
                                          int *status_out);
-int dirvote_compute_consensus(void);
 int dirvote_add_signatures(const char *detached_signatures_body);
-int dirvote_publish_consensus(void);
 
 /* Item access */
 const char *dirvote_get_pending_consensus(void);