浏览代码

Make some functions static

svn:r1857
Nick Mathewson 21 年之前
父节点
当前提交
537fb82cbb
共有 7 个文件被更改,包括 21 次插入20 次删除
  1. 4 2
      src/or/circuit.c
  2. 4 2
      src/or/connection.c
  3. 2 2
      src/or/cpuworker.c
  4. 2 2
      src/or/dns.c
  5. 2 6
      src/or/or.h
  6. 1 6
      src/or/rendclient.c
  7. 6 0
      src/or/rendcommon.c

+ 4 - 2
src/or/circuit.c

@@ -22,6 +22,8 @@ void circuit_expire_old_circuits(void);
 static void circuit_is_open(circuit_t *circ);
 static void circuit_is_open(circuit_t *circ);
 static void circuit_build_failed(circuit_t *circ);
 static void circuit_build_failed(circuit_t *circ);
 static circuit_t *circuit_establish_circuit(uint8_t purpose, const char *exit_nickname);
 static circuit_t *circuit_establish_circuit(uint8_t purpose, const char *exit_nickname);
+static void circuit_free(circuit_t *circ);
+static void circuit_free_cpath(crypt_path_t *cpath);
 
 
 /********* START VARIABLES **********/
 /********* START VARIABLES **********/
 
 
@@ -112,7 +114,7 @@ circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn) {
 
 
 /** Deallocate space associated with circ.
 /** Deallocate space associated with circ.
  */
  */
-void circuit_free(circuit_t *circ) {
+static void circuit_free(circuit_t *circ) {
   tor_assert(circ);
   tor_assert(circ);
   tor_assert(circ->magic == CIRCUIT_MAGIC);
   tor_assert(circ->magic == CIRCUIT_MAGIC);
   if (circ->n_crypto)
   if (circ->n_crypto)
@@ -139,7 +141,7 @@ void circuit_free(circuit_t *circ) {
 }
 }
 
 
 /** Deallocate space associated with the linked list <b>cpath</b>. */
 /** Deallocate space associated with the linked list <b>cpath</b>. */
-void circuit_free_cpath(crypt_path_t *cpath) {
+static void circuit_free_cpath(crypt_path_t *cpath) {
   crypt_path_t *victim, *head=cpath;
   crypt_path_t *victim, *head=cpath;
 
 
   if(!cpath)
   if(!cpath)

+ 4 - 2
src/or/connection.c

@@ -79,6 +79,8 @@ static int connection_handle_listener_read(connection_t *conn, int new_type);
 static int connection_receiver_bucket_should_increase(connection_t *conn);
 static int connection_receiver_bucket_should_increase(connection_t *conn);
 static int connection_finished_flushing(connection_t *conn);
 static int connection_finished_flushing(connection_t *conn);
 static int connection_finished_connecting(connection_t *conn);
 static int connection_finished_connecting(connection_t *conn);
+static int connection_read_to_buf(connection_t *conn);
+static int connection_process_inbuf(connection_t *conn);
 
 
 /**************************************************************/
 /**************************************************************/
 
 
@@ -702,7 +704,7 @@ int connection_handle_read(connection_t *conn) {
  *
  *
  * Return -1 if we want to break conn, else return 0.
  * Return -1 if we want to break conn, else return 0.
  */
  */
-int connection_read_to_buf(connection_t *conn) {
+static int connection_read_to_buf(connection_t *conn) {
   int result;
   int result;
   int at_most;
   int at_most;
 
 
@@ -1103,7 +1105,7 @@ int connection_send_destroy(uint16_t circ_id, connection_t *conn) {
  * This function just passes conn to the connection-specific
  * This function just passes conn to the connection-specific
  * connection_*_process_inbuf() function.
  * connection_*_process_inbuf() function.
  */
  */
-int connection_process_inbuf(connection_t *conn) {
+static int connection_process_inbuf(connection_t *conn) {
 
 
   tor_assert(conn);
   tor_assert(conn);
 
 

+ 2 - 2
src/or/cpuworker.c

@@ -34,7 +34,7 @@ static int num_cpuworkers_busy=0;
  * the last time we got a key rotation event. */
  * the last time we got a key rotation event. */
 static time_t last_rotation_time=0;
 static time_t last_rotation_time=0;
 
 
-int cpuworker_main(void *data);
+static int cpuworker_main(void *data);
 static int spawn_cpuworker(void);
 static int spawn_cpuworker(void);
 static void spawn_enough_cpuworkers(void);
 static void spawn_enough_cpuworkers(void);
 static void process_pending_task(connection_t *cpuworker);
 static void process_pending_task(connection_t *cpuworker);
@@ -183,7 +183,7 @@ done_processing:
  *          Onionskin challenge ONIONSKIN_REPLY_LEN
  *          Onionskin challenge ONIONSKIN_REPLY_LEN
  *          Negotiated keys     KEY_LEN*2+DIGEST_LEN*2
  *          Negotiated keys     KEY_LEN*2+DIGEST_LEN*2
  */
  */
-int cpuworker_main(void *data) {
+static int cpuworker_main(void *data) {
   unsigned char question[ONIONSKIN_CHALLENGE_LEN];
   unsigned char question[ONIONSKIN_CHALLENGE_LEN];
   unsigned char question_type;
   unsigned char question_type;
   int *fdarray = data;
   int *fdarray = data;

+ 2 - 2
src/or/dns.c

@@ -66,7 +66,7 @@ static void purge_expired_resolves(uint32_t now);
 static int assign_to_dnsworker(connection_t *exitconn);
 static int assign_to_dnsworker(connection_t *exitconn);
 static void dns_purge_resolve(struct cached_resolve *resolve);
 static void dns_purge_resolve(struct cached_resolve *resolve);
 static void dns_found_answer(char *address, uint32_t addr, char outcome);
 static void dns_found_answer(char *address, uint32_t addr, char outcome);
-int dnsworker_main(void *data);
+static int dnsworker_main(void *data);
 static int spawn_dnsworker(void);
 static int spawn_dnsworker(void);
 static void spawn_enough_dnsworkers(void);
 static void spawn_enough_dnsworkers(void);
 
 
@@ -532,7 +532,7 @@ int connection_dns_process_inbuf(connection_t *conn) {
  * The dnsworker runs indefinitely, until its connection is closed or an error
  * The dnsworker runs indefinitely, until its connection is closed or an error
  * occurs.
  * occurs.
  */
  */
-int dnsworker_main(void *data) {
+static int dnsworker_main(void *data) {
   char address[MAX_ADDRESSLEN];
   char address[MAX_ADDRESSLEN];
   unsigned char address_len;
   unsigned char address_len;
   char answer[5];
   char answer[5];

+ 2 - 6
src/or/or.h

@@ -867,7 +867,6 @@ void assert_buf_ok(buf_t *buf);
 extern char *circuit_state_to_string[];
 extern char *circuit_state_to_string[];
 circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
 circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
 void circuit_close_all_marked(void);
 void circuit_close_all_marked(void);
-void circuit_free(circuit_t *circ);
 void circuit_free_cpath(crypt_path_t *cpath);
 void circuit_free_cpath(crypt_path_t *cpath);
 int _circuit_mark_for_close(circuit_t *circ);
 int _circuit_mark_for_close(circuit_t *circ);
 
 
@@ -980,7 +979,6 @@ void connection_bucket_init(void);
 void connection_bucket_refill(struct timeval *now);
 void connection_bucket_refill(struct timeval *now);
 
 
 int connection_handle_read(connection_t *conn);
 int connection_handle_read(connection_t *conn);
-int connection_read_to_buf(connection_t *conn);
 
 
 int connection_fetch_from_buf(char *string, int len, connection_t *conn);
 int connection_fetch_from_buf(char *string, int len, connection_t *conn);
 
 
@@ -1008,8 +1006,6 @@ int connection_state_is_connecting(connection_t *conn);
 
 
 int connection_send_destroy(uint16_t circ_id, connection_t *conn);
 int connection_send_destroy(uint16_t circ_id, connection_t *conn);
 
 
-int connection_process_inbuf(connection_t *conn);
-
 void assert_connection_ok(connection_t *conn, time_t now);
 void assert_connection_ok(connection_t *conn, time_t now);
 
 
 /********************************* connection_edge.c ***************************/
 /********************************* connection_edge.c ***************************/
@@ -1071,7 +1067,6 @@ void cpu_init(void);
 void cpuworkers_rotate(void);
 void cpuworkers_rotate(void);
 int connection_cpu_finished_flushing(connection_t *conn);
 int connection_cpu_finished_flushing(connection_t *conn);
 int connection_cpu_process_inbuf(connection_t *conn);
 int connection_cpu_process_inbuf(connection_t *conn);
-int cpuworker_main(void *data);
 int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type,
 int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type,
                         void *task);
                         void *task);
 
 
@@ -1195,7 +1190,6 @@ int rend_client_rendezvous_acked(circuit_t *circ, const char *request, int reque
 int rend_client_receive_rendezvous(circuit_t *circ, const char *request, int request_len);
 int rend_client_receive_rendezvous(circuit_t *circ, const char *request, int request_len);
 void rend_client_desc_fetched(char *query, int success);
 void rend_client_desc_fetched(char *query, int success);
 
 
-int rend_cmp_service_ids(const char *one, const char *two);
 char *rend_client_get_random_intro(char *query);
 char *rend_client_get_random_intro(char *query);
 int rend_parse_rendezvous_address(char *address);
 int rend_parse_rendezvous_address(char *address);
 
 
@@ -1211,6 +1205,8 @@ typedef struct rend_service_descriptor_t {
   char **intro_points;
   char **intro_points;
 } rend_service_descriptor_t;
 } rend_service_descriptor_t;
 
 
+int rend_cmp_service_ids(const char *one, const char *two);
+
 void rend_process_relay_cell(circuit_t *circ, int command, int length,
 void rend_process_relay_cell(circuit_t *circ, int command, int length,
                              const char *payload);
                              const char *payload);
 
 

+ 1 - 6
src/or/rendclient.c

@@ -24,7 +24,7 @@ rend_client_introcirc_is_open(circuit_t *circ)
 /** Send the establish-rendezvous cell along a rendezvous circuit. if
 /** Send the establish-rendezvous cell along a rendezvous circuit. if
  * it fails, mark the circ for close and return -1. else return 0.
  * it fails, mark the circ for close and return -1. else return 0.
  */
  */
-int
+static int
 rend_client_send_establish_rendezvous(circuit_t *circ)
 rend_client_send_establish_rendezvous(circuit_t *circ)
 {
 {
   tor_assert(circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
   tor_assert(circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
@@ -389,11 +389,6 @@ void rend_client_desc_fetched(char *query, int success) {
   }
   }
 }
 }
 
 
-/** Return 0 if one and two are the same service ids, else -1 or 1 */
-int rend_cmp_service_ids(const char *one, const char *two) {
-  return strcasecmp(one,two);
-}
-
 /** strdup a nickname for a random introduction
 /** strdup a nickname for a random introduction
  * point of query. return NULL if error.
  * point of query. return NULL if error.
  */
  */

+ 6 - 0
src/or/rendcommon.c

@@ -10,6 +10,12 @@
 
 
 #include "or.h"
 #include "or.h"
 
 
+
+/** Return 0 if one and two are the same service ids, else -1 or 1 */
+int rend_cmp_service_ids(const char *one, const char *two) {
+  return strcasecmp(one,two);
+}
+
 /** Free the storage held by the service descriptor <b>desc</b>.
 /** Free the storage held by the service descriptor <b>desc</b>.
  */
  */
 void rend_service_descriptor_free(rend_service_descriptor_t *desc)
 void rend_service_descriptor_free(rend_service_descriptor_t *desc)