[or-cvs] Use a stricter set of warnings; make them all pass.

Nick Mathewson nickm at seul.org
Tue Nov 2 03:02:20 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv3912/src/or

Modified Files:
	connection.c dirserv.c main.c or.h relay.c routerlist.c 
	routerparse.c test.c 
Log Message:
Use a stricter set of warnings; make them all pass.

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -d -r1.273 -r1.274
--- connection.c	31 Oct 2004 20:28:41 -0000	1.273
+++ connection.c	2 Nov 2004 03:02:17 -0000	1.274
@@ -83,6 +83,7 @@
 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);
+static int connection_bucket_read_limit(connection_t *conn);
 
 /**************************************************************/
 
@@ -642,7 +643,7 @@
 extern int global_read_bucket, global_write_bucket;
 
 /** How many bytes at most can we read onto this connection? */
-int connection_bucket_read_limit(connection_t *conn) {
+static int connection_bucket_read_limit(connection_t *conn) {
   int at_most;
 
   /* do a rudimentary round-robin so one circuit can't hog a connection */

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- dirserv.c	2 Nov 2004 02:28:51 -0000	1.108
+++ dirserv.c	2 Nov 2004 03:02:17 -0000	1.109
@@ -24,6 +24,8 @@
                               char **router_status_out);
 static void directory_remove_unrecognized(void);
 static int dirserv_regenerate_directory(void);
+/* Should be static; exposed for testing */
+void add_fingerprint_to_dir(const char *nickname, const char *fp);
 
 /************** Fingerprint handling code ************/
 

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.346
retrieving revision 1.347
diff -u -d -r1.346 -r1.347
--- main.c	1 Nov 2004 08:24:34 -0000	1.346
+++ main.c	2 Nov 2004 03:02:17 -0000	1.347
@@ -1019,7 +1019,7 @@
 
 /** Called by exit() as we shut down the process.
  */
-void exit_function(void)
+static void exit_function(void)
 {
 /* XXX if we ever daemonize, this gets called immediately */
 #ifdef MS_WINDOWS
@@ -1096,7 +1096,7 @@
 }
 
 /** Read/create keys as needed, and echo our fingerprint to stdout. */
-void do_list_fingerprint(void)
+static void do_list_fingerprint(void)
 {
   char buf[FINGERPRINT_LEN+1];
   crypto_pk_env_t *k;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.452
retrieving revision 1.453
diff -u -d -r1.452 -r1.453
--- or.h	1 Nov 2004 21:46:27 -0000	1.452
+++ or.h	2 Nov 2004 03:02:17 -0000	1.453
@@ -1038,13 +1038,6 @@
 void circuit_reset_failure_count(int timeout);
 int connection_ap_handshake_attach_circuit(connection_t *conn);
 
-int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data,int reverse);
-int circuit_finish_handshake(circuit_t *circ, char *reply);
-int circuit_truncated(circuit_t *circ, crypt_path_t *layer);
-
-void assert_cpath_layer_ok(const crypt_path_t *c);
-void assert_circuit_ok(const circuit_t *c);
-
 /********************************* command.c ***************************/
 
 void command_process_cell(cell_t *cell, connection_t *conn);
@@ -1271,6 +1264,8 @@
 void handle_signals(int is_parent);
 void tor_cleanup(void);
 
+int tor_main(int argc, char *argv[]);
+
 /********************************* onion.c ***************************/
 
 int onion_pending_add(circuit_t *circ);

Index: relay.c
===================================================================
RCS file: /home/or/cvsroot/src/or/relay.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- relay.c	2 Nov 2004 02:28:51 -0000	1.15
+++ relay.c	2 Nov 2004 03:02:17 -0000	1.16
@@ -30,9 +30,6 @@
                                    crypt_path_t *layer_hint);
 static int
 circuit_consider_stop_edge_reading(circuit_t *circ, crypt_path_t *layer_hint);
-void connection_edge_consider_sending_sendme(connection_t *conn);
-
-
 
 /** Stats: how many relay cells have originated at this hop, or have
  * been relayed onward (not recognized at this hop)?

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- routerlist.c	28 Oct 2004 18:37:52 -0000	1.171
+++ routerlist.c	2 Nov 2004 03:02:17 -0000	1.172
@@ -737,7 +737,8 @@
  * will either be inserted into the routerlist or freed.  Returns 0 if the
  * router was added; -1 if it was not.
  */
-int router_add_to_routerlist(routerinfo_t *router) {
+static int
+router_add_to_routerlist(routerinfo_t *router) {
   int i;
   routerinfo_t *r;
   char id_digest[DIGEST_LEN];

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- routerparse.c	2 Nov 2004 02:28:51 -0000	1.69
+++ routerparse.c	2 Nov 2004 03:02:17 -0000	1.70
@@ -139,6 +139,8 @@
                                      crypto_pk_env_t *pkey,
                                      crypto_pk_env_t *declared_key);
 static crypto_pk_env_t *find_dir_signing_key(const char *str);
+/* static */ int is_obsolete_version(const char *myversion,
+                                     const char *versionlist);
 
 /** Set <b>digest</b> to the SHA-1 digest of the hash of the directory in
  * <b>s</b>.  Return 0 on success, nonzero on failure.

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- test.c	2 Nov 2004 02:28:51 -0000	1.137
+++ test.c	2 Nov 2004 03:02:17 -0000	1.138
@@ -23,27 +23,11 @@
 /* These functions are file-local, but are exposed so we can test. */
 void add_fingerprint_to_dir(const char *nickname, const char *fp);
 void get_platform_str(char *platform, size_t len);
-
-void
-dump_hex(char *s, size_t len)
-{
-  static const char TABLE[] = "0123456789ABCDEF";
-  unsigned char *d = s;
-  size_t i;
-  int j, nyb;
-  for(i=0;i<len;++i) {
-    for (j=1;j>=0;--j) {
-      nyb = (((int) d[i]) >> (j*4)) & 0x0f;
-      tor_assert(0 <= nyb);
-      tor_assert(nyb <= 15);
-      putchar(TABLE[nyb]);
-    }
-  }
-}
+int is_obsolete_version(const char *myversion, const char *start);
 
 static char temp_dir[256];
 
-void
+static void
 setup_directory(void)
 {
   static int is_setup = 0;
@@ -64,7 +48,7 @@
   is_setup = 1;
 }
 
-const char *
+static const char *
 get_fname(const char *name)
 {
   static char buf[1024];
@@ -73,7 +57,7 @@
   return buf;
 }
 
-void
+static void
 remove_directory(void)
 {
   DIR *dirp;
@@ -97,7 +81,7 @@
   rmdir(temp_dir);
 }
 
-void
+static void
 test_buffers(void) {
 #define MAX_BUF_SIZE 1024*1024
   char str[256];
@@ -223,7 +207,7 @@
   buf_free(buf);
 }
 
-void
+static void
 test_crypto_dh(void)
 {
   crypto_dh_env_t *dh1, *dh2;
@@ -258,7 +242,7 @@
   crypto_dh_free(dh2);
 }
 
-void
+static void
 test_crypto(void)
 {
   crypto_cipher_env_t *env1, *env2;
@@ -494,7 +478,7 @@
   free(data3);
 }
 
-void
+static void
 test_util(void) {
   struct timeval start, end;
   struct tm a_time;
@@ -694,7 +678,7 @@
   smartlist_free(sl);
 }
 
-void
+static void
 test_gzip(void)
 {
   char *buf1, *buf2=NULL, *buf3=NULL;
@@ -729,7 +713,8 @@
   tor_free(buf1);
 }
 
-static void* _squareAndRemoveK4(const char *key, void*val, void *data)
+static void * 
+_squareAndRemoveK4(const char *key, void*val, void *data)
 {
   int *ip = (int*)data;
   intptr_t v;
@@ -741,7 +726,8 @@
   return (void*)(v*v);
 }
 
-void test_strmap(void)
+static void
+test_strmap(void)
 {
   strmap_t *map;
   strmap_iter_t *iter;
@@ -815,7 +801,8 @@
   strmap_free(map,NULL);
 }
 
-void test_onion(void)
+static void 
+test_onion(void)
 {
 #if 0
   char **names;
@@ -833,7 +820,7 @@
 #endif
 }
 
-void
+static void
 test_onion_handshake(void)
 {
   /* client-side */
@@ -876,10 +863,8 @@
   crypto_free_pk_env(pk);
 }
 
-/* from routerparse.c */
-int is_obsolete_version(const char *myversion, const char *start);
 
-void
+static void
 test_dir_format(void)
 {
   char buf[8192], buf2[8192];
@@ -925,7 +910,7 @@
   get_platform_str(platform, sizeof(platform));
   memset(&r1,0,sizeof(r1));
   memset(&r2,0,sizeof(r2));
-  r1.address = "testaddr1.foo.bar";
+  r1.address = tor_strdup("testaddr1.foo.bar");
   r1.addr = 0xc0a80001u; /* 192.168.0.1 */
   r1.published_on = 0;
   r1.or_port = 9000;
@@ -937,7 +922,7 @@
   r1.bandwidthburst = 5000;
   r1.bandwidthcapacity = 10000;
   r1.exit_policy = NULL;
-  r1.nickname = "Magri";
+  r1.nickname = tor_strdup("Magri");
   r1.platform = tor_strdup(platform);
 
   ex1.policy_type = EXIT_POLICY_ACCEPT;
@@ -951,7 +936,7 @@
   ex2.msk = 0xFF000000u;
   ex2.prt_min = ex2.prt_max = 24;
   ex2.next = NULL;
-  r2.address = "tor.tor.tor";
+  r2.address = tor_strdup("tor.tor.tor");
   r2.addr = 0x0a030201u; /* 10.3.2.1 */
   r2.platform = tor_strdup(platform);
   r2.published_on = 5;
@@ -962,7 +947,7 @@
   r2.identity_pkey = pk1;
   r2.bandwidthrate = r2.bandwidthburst = r2.bandwidthcapacity = 3000;
   r2.exit_policy = &ex1;
-  r2.nickname = "Fred";
+  r2.nickname = tor_strdup("Fred");
 
   bw_lines = rep_hist_get_bandwidth_lines();
   test_assert(bw_lines);
@@ -1062,7 +1047,7 @@
   test_assert(router_dump_router_to_string(buf, 2048, &r2, pk1)>0);
   cp = buf;
   test_eq(dirserv_add_descriptor((const char**)&cp), 1);
-  options.Nickname = "DirServer";
+  options.Nickname = tor_strdup("DirServer");
   test_assert(!dirserv_dump_directory_to_string(buf,8192,pk3));
   cp = buf;
   test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3, 1));
@@ -1128,7 +1113,8 @@
 
 }
 
-void test_rend_fns(void)
+static void
+test_rend_fns(void)
 {
   char address1[] = "fooaddress.onion";
   char address2[] = "aaaaaaaaaaaaaaaa.onion";
@@ -1182,7 +1168,7 @@
   atexit(remove_directory);
 
 //  puts("========================== Buffers =========================");
-//  test_buffers();
+  if (0) test_buffers();
   puts("\n========================== Crypto ==========================");
   // add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout);
   test_crypto();



More information about the tor-commits mailing list