[or-cvs] Add a new warning to our "warn a lot" list: unused paramete...

Nick Mathewson nickm at seul.org
Sun Jun 4 22:42:15 UTC 2006


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv18936/src/or

Modified Files:
	circuitbuild.c circuituse.c config.c connection.c control.c 
	directory.c dirserv.c dns.c main.c or.h relay.c rendclient.c 
	rendservice.c router.c routerlist.c 
Log Message:
Add a new warning to our "warn a lot" list: unused parameters.  This means we have to explicitly "use" unuseds, but it can catch bugs.  (It caught two coding mistakes so far.)

Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.234
retrieving revision 1.235
diff -u -p -d -r1.234 -r1.235
--- circuitbuild.c	30 May 2006 06:17:28 -0000	1.234
+++ circuitbuild.c	4 Jun 2006 22:42:12 -0000	1.235
@@ -1508,6 +1508,7 @@ choose_good_entry_server(uint8_t purpose
   routerinfo_t *r, *choice;
   smartlist_t *excluded;
   or_options_t *options = get_options();
+  (void)purpose; /* not used yet. */
 
   if (state && options->UseEntryGuards) {
     return choose_random_entry(state);

Index: circuituse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -p -d -r1.126 -r1.127
--- circuituse.c	30 May 2006 06:19:06 -0000	1.126
+++ circuituse.c	4 Jun 2006 22:42:12 -0000	1.127
@@ -605,6 +605,10 @@ circuit_testing_failed(circuit_t *circ, 
   log_info(LD_GENERAL,
            "Our testing circuit (to see if your ORPort is reachable) "
            "has failed. I'll try again later.");
+
+  /* These aren't used yet. */
+  (void)circ;
+  (void)at_last_hop;
 }
 
 /** The circuit <b>circ</b> has just become open. Take the next

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.562
retrieving revision 1.563
diff -u -p -d -r1.562 -r1.563
--- config.c	24 May 2006 11:13:03 -0000	1.562
+++ config.c	4 Jun 2006 22:42:12 -0000	1.563
@@ -1489,6 +1489,7 @@ static void
 option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
 {
   void *lvalue = STRUCT_VAR_P(options, var->var_offset);
+  (void)fmt; /* unused */
   switch (var->type) {
     case CONFIG_TYPE_STRING:
       tor_free(*(char**)lvalue);
@@ -3601,6 +3602,10 @@ static int
 or_state_validate(or_state_t *old_state, or_state_t *state,
                   int from_setconf, char **msg)
 {
+  /* We don't use these; only options do. Still, we need to match that
+   * signature. */
+  (void) from_setconf;
+  (void) old_state;
   if (entry_guards_parse_state(state, 0, msg)<0) {
     return -1;
   }

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.451
retrieving revision 1.452
diff -u -p -d -r1.451 -r1.452
--- connection.c	30 May 2006 06:23:44 -0000	1.451
+++ connection.c	4 Jun 2006 22:42:12 -0000	1.452
@@ -1107,6 +1107,9 @@ connection_bucket_refill(struct timeval 
   connection_t *conn;
   connection_t **carray;
   or_options_t *options = get_options();
+  /* Not used, but it should be! We might have rolled over more than one
+   * second! XXXX */
+  (void) now;
 
   /* refill the global buckets */
   if (global_read_bucket < (int)options->BandwidthBurst) {
@@ -2018,6 +2021,7 @@ connection_reached_eof(connection_t *con
 void
 assert_connection_ok(connection_t *conn, time_t now)
 {
+  (void) now; /* XXXX unused. */
   tor_assert(conn);
   tor_assert(conn->magic == CONNECTION_MAGIC);
   tor_assert(conn->type >= _CONN_TYPE_MIN);

Index: control.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -p -d -r1.192 -r1.193
--- control.c	24 May 2006 23:03:28 -0000	1.192
+++ control.c	4 Jun 2006 22:42:12 -0000	1.193
@@ -790,6 +790,7 @@ handle_control_getconf(connection_t *con
   int v0 = STATE_IS_V0(conn->state);
 
   questions = smartlist_create();
+  (void) body_len; /* body is null-terminated; so we can ignore len. */
   if (v0) {
     smartlist_split_string(questions, body, "\n",
                            SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
@@ -1077,6 +1078,8 @@ static int
 handle_control_saveconf(connection_t *conn, uint32_t len,
                         const char *body)
 {
+  (void) len;
+  (void) body;
   if (options_save_current()<0) {
     if (STATE_IS_V0(conn->state))
       send_control0_error(conn, ERR_INTERNAL,
@@ -1157,6 +1160,8 @@ handle_control_mapaddress(connection_t *
   char *r;
   size_t sz;
   int v0 = STATE_IS_V0(conn->state);
+  (void) len; /* body is null-terminated, so it's safe to ignore the length. */
+
   lines = smartlist_create();
   elts = smartlist_create();
   reply = smartlist_create();
@@ -1542,6 +1547,7 @@ handle_control_getinfo(connection_t *con
   char *msg = NULL, *ans = NULL;
   size_t msg_len;
   int v0 = STATE_IS_V0(conn->state);
+  (void) len; /* body is null-terminated, so it's safe to ignore the length. */
 
   questions = smartlist_create();
   if (v0)
@@ -1803,6 +1809,7 @@ handle_control_setpurpose(connection_t *
   routerinfo_t *ri = NULL;
   uint8_t new_purpose;
   smartlist_t *args = smartlist_create();
+  (void) len; /* body is null-terminated, so it's safe to ignore the length. */
   smartlist_split_string(args, body, " ",
                          SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
   if (smartlist_len(args)<2) {
@@ -2779,6 +2786,7 @@ void
 control_event_logmsg(int severity, unsigned int domain, const char *msg)
 {
   int oldlog, event;
+  (void) domain;
 
   if (disable_log_messages)
     return;

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.371
retrieving revision 1.372
diff -u -p -d -r1.371 -r1.372
--- directory.c	18 Apr 2006 03:07:24 -0000	1.371
+++ directory.c	4 Jun 2006 22:42:12 -0000	1.372
@@ -324,6 +324,8 @@ connection_dir_download_routerdesc_faile
   /* Try again. No need to increment the failure count for routerdescs, since
    * it's not their fault.*/
   /* update_router_descriptor_downloads(time(NULL)); */
+  (void) conn;
+  /* XXXX Why did the above get commented out? -NM */
 }
 
 /** Helper for directory_initiate_command_(router|trusted_dir): send the
@@ -1331,7 +1333,8 @@ directory_dump_request_log(void)
 static void
 note_request(const char *key, size_t bytes)
 {
-  return;
+  (void)key;
+  (void)bytes;
 }
 
 char *
@@ -1355,6 +1358,9 @@ directory_handle_command_get(connection_
   char *url = NULL;
   char tmp[8192];
   char date[RFC1123_TIME_LEN+1];
+  /* We ignore the body of a GET request. */
+  (void)body;
+  (void)body_len;
 
   log_debug(LD_DIRSERV,"Received GET command.");
 

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -p -d -r1.330 -r1.331
--- dirserv.c	28 May 2006 16:14:26 -0000	1.330
+++ dirserv.c	4 Jun 2006 22:42:12 -0000	1.331
@@ -1633,6 +1633,7 @@ dirserv_orconn_tls_done(const char *addr
   tor_assert(address);
   tor_assert(digest_rcvd);
   tor_assert(nickname_rcvd);
+  (void) as_advertised; // XXXX This should really be implemented. -NM
 
   // XXXXNM We should really have a better solution here than dropping
   // XXXXNM whole routers; otherwise, they come back way too easily.

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -p -d -r1.186 -r1.187
--- dns.c	3 Jun 2006 21:41:14 -0000	1.186
+++ dns.c	4 Jun 2006 22:42:12 -0000	1.187
@@ -1057,18 +1057,21 @@ dnsworkers_rotate(void)
 int
 connection_dns_finished_flushing(connection_t *conn)
 {
+  (void)conn;
   tor_assert(0);
   return 0;
 }
 int
 connection_dns_process_inbuf(connection_t *conn)
 {
+  (void)conn;
   tor_assert(0);
   return 0;
 }
 int
 connection_dns_reached_eof(connection_t *conn)
 {
+  (void)conn;
   tor_assert(0);
   return 0;
 }

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.645
retrieving revision 1.646
diff -u -p -d -r1.645 -r1.646
--- main.c	28 May 2006 16:07:44 -0000	1.645
+++ main.c	4 Jun 2006 22:42:12 -0000	1.646
@@ -397,6 +397,8 @@ static void
 conn_read_callback(int fd, short event, void *_conn)
 {
   connection_t *conn = _conn;
+  (void)fd;
+  (void)event;
 
   log_debug(LD_NET,"socket %d wants to read.",conn->s);
 
@@ -427,6 +429,8 @@ static void
 conn_write_callback(int fd, short events, void *_conn)
 {
   connection_t *conn = _conn;
+  (void)fd;
+  (void)events;
 
   LOG_FN_CONN(conn, (LOG_DEBUG, LD_NET, "socket %d wants to write.",conn->s));
 
@@ -534,6 +538,7 @@ void
 directory_all_unreachable(time_t now)
 {
   connection_t *conn;
+  (void)now;
 
   stats_n_seconds_working=0; /* reset it */
 
@@ -828,7 +833,7 @@ run_scheduled_events(time_t now)
     }
     mark_my_descriptor_dirty_if_older_than(
                                   now - FORCE_REGENERATE_DESCRIPTOR_INTERVAL);
-    consider_publishable_server(now, 0);
+    consider_publishable_server(0);
     /* also, check religiously for reachability, if it's within the first
      * 20 minutes of our uptime. */
     if (server_mode(options) &&
@@ -925,6 +930,9 @@ second_elapsed_callback(int fd, short ev
   size_t bytes_read;
   int seconds_elapsed;
   or_options_t *options = get_options();
+  (void)fd;
+  (void)event;
+  (void)args;
   if (!timeout_event) {
     timeout_event = tor_malloc_zero(sizeof(struct event));
     evtimer_set(timeout_event, second_elapsed_callback, NULL);
@@ -1227,6 +1235,8 @@ static void
 signal_callback(int fd, short events, void *arg)
 {
   uintptr_t sig = (uintptr_t)arg;
+  (void)fd;
+  (void)events;
   switch (sig)
     {
     case SIGTERM:

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.834
retrieving revision 1.835
diff -u -p -d -r1.834 -r1.835
--- or.h	3 Jun 2006 21:41:14 -0000	1.834
+++ or.h	4 Jun 2006 22:42:12 -0000	1.835
@@ -2227,7 +2227,7 @@ void consider_testing_reachability(void)
 void router_orport_found_reachable(void);
 void router_dirport_found_reachable(void);
 void server_has_changed_ip(void);
-void consider_publishable_server(time_t now, int force);
+void consider_publishable_server(int force);
 
 int authdir_mode(or_options_t *options);
 int clique_mode(or_options_t *options);

Index: relay.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/relay.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -p -d -r1.100 -r1.101
--- relay.c	13 Feb 2006 10:32:58 -0000	1.100
+++ relay.c	4 Jun 2006 22:42:13 -0000	1.101
@@ -654,6 +654,7 @@ connection_edge_process_end_not_open(
   struct in_addr in;
   routerinfo_t *exitrouter;
   int reason = *(cell->payload+RELAY_HEADER_SIZE);
+  (void) layer_hint; /* unused */
 
   if (rh->length > 0 && edge_reason_is_retriable(reason) &&
       conn->type == CONN_TYPE_AP) {

Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendclient.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -p -d -r1.107 -r1.108
--- rendclient.c	6 Mar 2006 00:25:39 -0000	1.107
+++ rendclient.c	4 Jun 2006 22:42:13 -0000	1.108
@@ -183,6 +183,7 @@ rend_client_introduction_acked(circuit_t
                                const char *request, size_t request_len)
 {
   circuit_t *rendcirc;
+  (void) request; // XXXX Use this.
 
   if (circ->purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
     log_warn(LD_PROTOCOL,
@@ -342,6 +343,8 @@ int
 rend_client_rendezvous_acked(circuit_t *circ, const char *request,
                              size_t request_len)
 {
+  (void) request;
+  (void) request_len;
   /* we just got an ack for our establish-rendezvous. switch purposes. */
   if (circ->purpose != CIRCUIT_PURPOSE_C_ESTABLISH_REND) {
     log_warn(LD_PROTOCOL,"Got a rendezvous ack when we weren't expecting one. "

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendservice.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -p -d -r1.160 -r1.161
--- rendservice.c	18 Apr 2006 03:07:24 -0000	1.160
+++ rendservice.c	4 Jun 2006 22:42:13 -0000	1.161
@@ -769,6 +769,8 @@ rend_service_intro_established(circuit_t
                                size_t request_len)
 {
   rend_service_t *service;
+  (void) request;
+  (void) request_len;
 
   if (circuit->purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
     log_warn(LD_PROTOCOL,

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.263
retrieving revision 1.264
diff -u -p -d -r1.263 -r1.264
--- router.c	26 May 2006 16:29:33 -0000	1.263
+++ router.c	4 Jun 2006 22:42:13 -0000	1.264
@@ -480,7 +480,7 @@ router_orport_found_reachable(void)
                    " Publishing server descriptor." : "");
     can_reach_or_port = 1;
     mark_my_descriptor_dirty();
-    consider_publishable_server(time(NULL), 1);
+    consider_publishable_server(1);
   }
 }
 
@@ -569,7 +569,7 @@ proxy_mode(or_options_t *options)
  * - We have the AuthoritativeDirectory option set.
  */
 static int
-decide_if_publishable_server(time_t now)
+decide_if_publishable_server(void)
 {
   or_options_t *options = get_options();
 
@@ -593,7 +593,7 @@ decide_if_publishable_server(time_t now)
  * determine what IP address and ports to test.
  */
 void
-consider_publishable_server(time_t now, int force)
+consider_publishable_server(int force)
 {
   int rebuilt;
 
@@ -601,7 +601,7 @@ consider_publishable_server(time_t now, 
     return;
 
   rebuilt = router_rebuild_descriptor(0);
-  if (decide_if_publishable_server(now)) {
+  if (decide_if_publishable_server()) {
     set_server_advertised(1);
     if (rebuilt == 0)
       router_upload_dir_desc_to_dirservers(force);
@@ -951,6 +951,7 @@ check_descriptor_ipaddress_changed(time_
 {
   uint32_t prev, cur;
   or_options_t *options = get_options();
+  (void) now;
 
   if (!desc_routerinfo)
     return;

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.515
retrieving revision 1.516
diff -u -p -d -r1.515 -r1.516
--- routerlist.c	30 May 2006 06:19:48 -0000	1.515
+++ routerlist.c	4 Jun 2006 22:42:13 -0000	1.516
@@ -2528,9 +2528,9 @@ update_networkstatus_downloads(time_t no
 {
   or_options_t *options = get_options();
   if (options->DirPort)
-    update_networkstatus_cache_downloads(time(NULL));
+    update_networkstatus_cache_downloads(now);
   else
-    update_networkstatus_client_downloads(time(NULL));
+    update_networkstatus_client_downloads(now);
 }
 
 /** Return 1 if all running sufficiently-stable routers will reject
@@ -2685,6 +2685,7 @@ compute_recommended_versions(time_t now,
   smartlist_t *combined, *recommended;
   int n_versioning;
   char *result;
+  (void) now; /* right now, we consider *all* ors. */
 
   if (!networkstatus_list)
     return tor_strdup("<none>");
@@ -3508,6 +3509,7 @@ update_router_descriptor_cache_downloads
   int i, j, n;
   int n_download;
   or_options_t *options = get_options();
+  (void) now;
 
   if (!options->DirPort) {
     log_warn(LD_BUG, "Called update_router_descriptor_cache_downloads() "



More information about the tor-commits mailing list