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

[or-cvs] fix the assumption that uninitialized variables are 0



Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	control.c routerlist.c 
Log Message:
fix the assumption that uninitialized variables are 0
clean up router_load_single_router() more


Index: control.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- control.c	3 May 2005 10:04:08 -0000	1.81
+++ control.c	18 May 2005 03:52:07 -0000	1.82
@@ -827,7 +827,7 @@
 handle_control_postdescriptor(connection_t *conn, uint32_t len,
                               const char *body)
 {
-  const char *msg;
+  const char *msg=NULL;
   switch (router_load_single_router(body, &msg)) {
   case -1:
     send_control_error(conn,ERR_SYNTAX,msg?msg: "Could not parse descriptor");

Index: routerlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.234
retrieving revision 1.235
diff -u -d -r1.234 -r1.235
--- routerlist.c	18 May 2005 03:42:46 -0000	1.234
+++ routerlist.c	18 May 2005 03:52:07 -0000	1.235
@@ -908,21 +908,22 @@
 router_load_single_router(const char *s, const char **msg)
 {
   routerinfo_t *ri;
+  tor_assert(msg);
 
   if (!(ri = router_parse_entry_from_string(s, NULL))) {
     log_fn(LOG_WARN, "Error parsing router descriptor; dropping.");
-    if (msg) *msg = "Couldn't parse router descriptor";
+    *msg = "Couldn't parse router descriptor";
     return -1;
   }
   if (router_is_me(ri)) {
     log_fn(LOG_WARN, "Router's identity key matches mine; dropping.");
-    if (msg) *msg = "Router's identity key matches mine.";
+    *msg = "Router's identity key matches mine.";
     routerinfo_free(ri);
     return 0;
   }
   if (router_resolve(ri)<0) {
     log_fn(LOG_WARN, "Couldn't resolve router address; dropping.");
-    if (msg) *msg = "Couldn't resolve router address.";
+    *msg = "Couldn't resolve router address.";
     routerinfo_free(ri);
     return 0;
   }
@@ -934,7 +935,7 @@
   }
   if (router_add_to_routerlist(ri, msg)<0) {
     log_fn(LOG_WARN, "Couldn't add router to list; dropping.");
-    if (msg) *msg = "Couldn't add router to list.";
+    *msg = "Couldn't add router to list.";
     /* ri is already freed */
     return 0;
   } else {