[or-cvs] r11750: Make some functions static; remove some dead code. (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Tue Oct 2 20:35:24 UTC 2007


Author: nickm
Date: 2007-10-02 16:35:23 -0400 (Tue, 02 Oct 2007)
New Revision: 11750

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/aes.c
   tor/trunk/src/or/config.c
   tor/trunk/src/or/connection.c
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/dirvote.c
   tor/trunk/src/or/or.h
Log:
 r15512 at catbus:  nickm | 2007-10-02 16:27:43 -0400
 Make some functions static; remove some dead code.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15512] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/ChangeLog	2007-10-02 20:35:23 UTC (rev 11750)
@@ -37,7 +37,10 @@
       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:
     - Set up moria1 and tor26 as the first v3 directory authorities. See

Modified: tor/trunk/src/common/aes.c
===================================================================
--- tor/trunk/src/common/aes.c	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/src/common/aes.c	2007-10-02 20:35:23 UTC (rev 11750)
@@ -311,29 +311,6 @@
   }
 }
 
-#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_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 */

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/src/or/config.c	2007-10-02 20:35:23 UTC (rev 11750)
@@ -611,6 +611,8 @@
 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 @@
  * 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 @@
 /**
  * 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 @@
 /** 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;

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/src/or/connection.c	2007-10-02 20:35:23 UTC (rev 11750)
@@ -2369,6 +2369,7 @@
   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 @@
   });
   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

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/src/or/connection_edge.c	2007-10-02 20:35:23 UTC (rev 11750)
@@ -30,6 +30,7 @@
 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 @@
  * 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;

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/src/or/dirvote.c	2007-10-02 20:35:23 UTC (rev 11750)
@@ -19,9 +19,11 @@
 static char *list_v3_auth_ids(void);
 static void dirvote_fetch_missing_votes(void);
 static void dirvote_fetch_missing_signatures(void);
+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);
 
-/* XXXX020 lots of the functions here could be made static. Do so. */
-
 /* =====
  * Voting and consensus generation
  * ===== */
@@ -858,31 +860,7 @@
   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
 networkstatus_add_detached_signatures(networkstatus_vote_t *target,
@@ -1217,7 +1195,7 @@
 
 /** 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 @@
 }
 
 /** 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 @@
  * 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 @@
   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 @@
 
 /** 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? */

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-10-02 20:19:43 UTC (rev 11749)
+++ tor/trunk/src/or/or.h	2007-10-02 20:35:23 UTC (rev 11750)
@@ -2412,17 +2412,14 @@
 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_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 @@
 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_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);



More information about the tor-commits mailing list