[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Tricksy compiler warnings! We hates them, hates them foreve...



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

Modified Files:
	circuitbuild.c circuitlist.c config.c connection.c 
	connection_edge.c directory.c main.c or.h router.c 
	routerlist.c routerparse.c 
Log Message:
Tricksy compiler warnings! We hates them, hates them forever, my precious!

Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- circuitbuild.c	27 Oct 2004 06:37:34 -0000	1.44
+++ circuitbuild.c	27 Oct 2004 21:14:10 -0000	1.45
@@ -71,7 +71,7 @@
   char buf[1024];
   char *s = buf;
   struct crypt_path_t *hop;
-  char *states[] = {"closed", "waiting for keys", "open"};
+  const char *states[] = {"closed", "waiting for keys", "open"};
   routerinfo_t *router;
   tor_assert(CIRCUIT_IS_ORIGIN(circ));
   tor_assert(circ->cpath);
@@ -144,7 +144,7 @@
  */
 static void
 circuit_dump_details(int severity, circuit_t *circ, int poll_index,
-                     char *type, int this_circid, int other_circid) {
+                     const char *type, int this_circid, int other_circid) {
   struct crypt_path_t *hop;
   log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d",
       poll_index, type, this_circid, other_circid, circ->state,

Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitlist.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- circuitlist.c	24 Oct 2004 17:11:44 -0000	1.13
+++ circuitlist.c	27 Oct 2004 21:14:10 -0000	1.14
@@ -17,7 +17,7 @@
 circuit_t *global_circuitlist=NULL;
 
 /** Array of strings to make circ-\>state human-readable */
-char *circuit_state_to_string[] = {
+const char *circuit_state_to_string[] = {
   "doing handshakes",        /* 0 */
   "processing the onion",    /* 1 */
   "connecting to firsthop",  /* 2 */

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- config.c	27 Oct 2004 18:14:38 -0000	1.191
+++ config.c	27 Oct 2004 21:14:10 -0000	1.192
@@ -28,8 +28,8 @@
 
 /* An abbreviation for a configuration option allowed on the command line */
 typedef struct config_abbrev_t {
-  char *abbreviated;
-  char *full;
+  const char *abbreviated;
+  const char *full;
   int commandline_only;
 } config_abbrev_t;
 
@@ -48,13 +48,13 @@
   PLURAL(RendNode),
   PLURAL(RendExcludeNode),
   { "l",        "LogLevel" , 1},
-  { NULL, NULL },
+  { NULL, NULL , 0},
 };
 #undef PLURAL
 
 /* A variable allowed in the configuration file or on the command line */
 typedef struct config_var_t {
-  char *name; /**< The full keyword (case insensitive) */
+  const char *name; /**< The full keyword (case insensitive) */
   config_type_t type; /**< How to interpret the type and turn it into a value */
   off_t var_offset; /**< Offset of the corresponding member of or_options_t */
 } config_var_t;
@@ -411,8 +411,8 @@
   options->SocksPort = 9050;
 
   options->AllowUnverifiedNodes = smartlist_create();
-  smartlist_add(options->AllowUnverifiedNodes, "middle");
-  smartlist_add(options->AllowUnverifiedNodes, "rendezvous");
+  smartlist_add(options->AllowUnverifiedNodes, tor_strdup("middle"));
+  smartlist_add(options->AllowUnverifiedNodes, tor_strdup("rendezvous"));
 
   config_free_lines(options->ExitPolicy);
   options->ExitPolicy = NULL;
@@ -572,6 +572,11 @@
     smartlist_free(options->FirewallPorts);
     options->FirewallPorts = NULL;
   }
+  if (options->AllowUnverifiedNodes) {
+    SMARTLIST_FOREACH(options->AllowUnverifiedNodes, char *, cp, tor_free(cp));
+    smartlist_free(options->AllowUnverifiedNodes);
+    options->AllowUnverifiedNodes = NULL;
+  }
 }
 
 /** Set <b>options</b> to hold reasonable defaults for most options.

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -d -r1.271 -r1.272
--- connection.c	25 Oct 2004 06:16:26 -0000	1.271
+++ connection.c	27 Oct 2004 21:14:11 -0000	1.272
@@ -16,7 +16,7 @@
 extern int shutting_down; /* whether we should refuse new connections */
 
 /** Array of strings to make conn-\>type human-readable. */
-char *conn_type_to_string[] = {
+const char *conn_type_to_string[] = {
   "",            /* 0 */
   "OP listener", /* 1 */
   "OP",          /* 2 */
@@ -32,7 +32,7 @@
 };
 
 /** Array of string arrays to make {conn-\>type,conn-\>state} human-readable. */
-char *conn_state_to_string[][_CONN_TYPE_MAX+1] = {
+const char *conn_state_to_string[][_CONN_TYPE_MAX+1] = {
   { NULL }, /* no type associated with 0 */
   { NULL }, /* op listener, obsolete */
   { NULL }, /* op, obsolete */

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -d -r1.220 -r1.221
--- connection_edge.c	27 Oct 2004 06:48:16 -0000	1.220
+++ connection_edge.c	27 Oct 2004 21:14:11 -0000	1.221
@@ -11,7 +11,6 @@
 #include "tree.h"
 
 extern or_options_t options; /* command-line and config-file options */
-extern char *conn_state_to_string[][_CONN_TYPE_MAX+1]; /* from connection.c */
 
 static struct exit_policy_t *socks_policy = NULL;
 

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -d -r1.155 -r1.156
--- directory.c	27 Oct 2004 06:48:16 -0000	1.155
+++ directory.c	27 Oct 2004 21:14:11 -0000	1.156
@@ -314,7 +314,7 @@
   char hoststring[128];
   char url[128];
   int use_newer = 0;
-  char *httpcommand = NULL;
+  const char *httpcommand = NULL;
 
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DIR);

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.341
retrieving revision 1.342
diff -u -d -r1.341 -r1.342
--- main.c	27 Oct 2004 06:37:34 -0000	1.341
+++ main.c	27 Oct 2004 21:14:11 -0000	1.342
@@ -16,9 +16,6 @@
 
 /********* START VARIABLES **********/
 
-/* declared in connection.c */
-extern char *conn_state_to_string[][_CONN_TYPE_MAX+1];
-
 or_options_t options; /**< Command-line and config-file options. */
 int global_read_bucket; /**< Max number of bytes I can read this second. */
 int global_write_bucket; /**< Max number of bytes I can write this second. */

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.446
retrieving revision 1.447
diff -u -d -r1.446 -r1.447
--- or.h	27 Oct 2004 18:16:37 -0000	1.446
+++ or.h	27 Oct 2004 21:14:11 -0000	1.447
@@ -478,8 +478,8 @@
   int marked_for_close; /**< Boolean: should we close this conn on the next
                          * iteration of the main loop?
                          */
-  char *marked_for_close_file; /**< For debugging: in which file were we marked
-                                * for close? */
+  const char *marked_for_close_file; /**< For debugging: in which file were
+                                      * we marked for close? */
   int hold_open_until_flushed; /**< Despite this connection's being marked
                                 * for close, do we flush it before closing it?
                                 */
@@ -708,8 +708,8 @@
 
   int marked_for_close; /**< Should we close this circuit at the end of the
                          * main loop? */
-  char *marked_for_close_file; /**< For debugging: in which file was this
-                                * circuit marked for close? */
+  const char *marked_for_close_file; /**< For debugging: in which file was this
+                                      * circuit marked for close? */
 
   /** The IPv4 address of the OR that is next in this circuit. */
   uint32_t n_addr;
@@ -990,7 +990,7 @@
 
 /********************************* circuitlist.c ***********************/
 
-extern char *circuit_state_to_string[];
+extern const char *circuit_state_to_string[];
 void circuit_close_all_marked(void);
 circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
 void circuit_free_cpath_node(crypt_path_t *victim);
@@ -1071,8 +1071,8 @@
 #define CONN_TYPE_TO_STRING(t) (((t) < _CONN_TYPE_MIN || (t) > _CONN_TYPE_MAX) ? \
   "Unknown" : conn_type_to_string[(t)])
 
-extern char *conn_type_to_string[];
-extern char *conn_state_to_string[][_CONN_TYPE_MAX+1];
+extern const char *conn_type_to_string[];
+extern const char *conn_state_to_string[][_CONN_TYPE_MAX+1];
 
 connection_t *connection_new(int type);
 void connection_free(connection_t *conn);
@@ -1443,7 +1443,8 @@
 int router_nickname_matches(routerinfo_t *router, const char *nickname);
 int router_is_unreliable_router(routerinfo_t *router, int need_uptime, int need_bw);
 routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl);
-routerinfo_t *router_choose_random_node(char *preferred, char *excluded,
+routerinfo_t *router_choose_random_node(const char *preferred,
+                                        const char *excluded,
                                         struct smartlist_t *excludedsmartlist,
                                         int preferuptime, int preferbandwidth,
                                         int allow_unverified, int strict);

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- router.c	27 Oct 2004 06:37:34 -0000	1.105
+++ router.c	27 Oct 2004 21:14:11 -0000	1.106
@@ -449,7 +449,7 @@
 
   /* Else, append the default exitpolicy. */
   default_policy.key = NULL;
-  default_policy.value = DEFAULT_EXIT_POLICY;
+  default_policy.value = (char*)DEFAULT_EXIT_POLICY;
   default_policy.next = NULL;
   config_parse_exit_policy(&default_policy, &router->exit_policy);
 }

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -d -r1.169 -r1.170
--- routerlist.c	27 Oct 2004 06:48:16 -0000	1.169
+++ routerlist.c	27 Oct 2004 21:14:11 -0000	1.170
@@ -458,7 +458,8 @@
  * available.  If <b>strict</b> is true, never pick any node besides
  * those in <b>preferred</b>.
  */
-routerinfo_t *router_choose_random_node(char *preferred, char *excluded,
+routerinfo_t *router_choose_random_node(const char *preferred,
+                                        const char *excluded,
                                         smartlist_t *excludedsmartlist,
                                         int preferuptime, int preferbandwidth,
                                         int allow_unverified, int strict)
@@ -1112,7 +1113,7 @@
     ++cp;
     if (strlen(cp) != HEX_DIGEST_LEN) {
       log_fn(LOG_WARN, "Bad length (%d) on digest in router status entry (%s)",
-             strlen(cp), s);
+             (int)strlen(cp), s);
       return -1;
     }
     strlcpy(hexdigest, cp, sizeof(hexdigest));

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- routerparse.c	27 Oct 2004 06:37:34 -0000	1.66
+++ routerparse.c	27 Oct 2004 21:14:11 -0000	1.67
@@ -64,7 +64,7 @@
   size_t object_size;             /**< Bytes in object_body */
   char *object_body;           /**< Contents of object, base64-decoded. */
   crypto_pk_env_t *key;        /**< For public keys only. */
-  char *error;                 /**< For _ERR tokens only. */
+  const char *error;           /**< For _ERR tokens only. */
 } directory_token_t;
 
 /* ********************************************************************** */
@@ -95,7 +95,7 @@
 
 /** Table mapping keywords to token value and to argument rules. */
 static struct {
-  char *t; int v; arg_syntax s; obj_syntax os; where_syntax ws;
+  const char *t; int v; arg_syntax s; obj_syntax os; where_syntax ws;
 } token_table[] = {
   { "accept",              K_ACCEPT,              ARGS,    NO_OBJ,  RTR_ONLY },
   { "directory-signature", K_DIRECTORY_SIGNATURE, ARGS,    NEED_OBJ,DIR_ONLY},