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

[or-cvs] r7020: Add more warnings to the list of those we tolerate. Start us (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2006-08-11 03:09:17 -0400 (Fri, 11 Aug 2006)
New Revision: 7020

Modified:
   tor/trunk/
   tor/trunk/configure.in
   tor/trunk/src/common/compat.h
   tor/trunk/src/common/container.h
   tor/trunk/src/common/util.h
   tor/trunk/src/or/circuitbuild.c
   tor/trunk/src/or/config.c
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/test.c
Log:
 r7324@Kushana:  nickm | 2006-08-10 23:23:15 -0700
 Add more warnings to the list of those we tolerate. Start using GCC attributes more, for better error checking and better code generation.



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   - 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8245
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:7014
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:7323
   + 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8245
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:7014
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:7324

Modified: tor/trunk/configure.in
===================================================================
--- tor/trunk/configure.in	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/configure.in	2006-08-11 07:09:17 UTC (rev 7020)
@@ -645,7 +645,7 @@
 fi
 # Add some more warnings which we use in the cvs version but not in the
 # released versions.  (Some relevant gcc versions can't handle these.)
-#CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Winit-self -Wwrite-strings -Waggregate-return -Wmissing-declarations -Wmissing-field-initializers -Wredundant-decls -Winline"
+#CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Winit-self -Wwrite-strings -Waggregate-return -Wmissing-declarations -Wmissing-field-initializers -Wredundant-decls -Winline -Wnested-externs -Wswitch-enums"
 # Add these in when you feel like fun.
 #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definition"
 

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/common/compat.h	2006-08-11 07:09:17 UTC (rev 7020)
@@ -89,6 +89,19 @@
 #define DBL_TO_U64(x) ((uint64_t) (x))
 #endif
 
+/* GCC has several useful attributes. */
+#ifdef __GNUC__
+#define ATTR_NORETURN __attribute__((noreturn))
+#define ATTR_PURE __attribute__((pure))
+#define ATTR_MALLOC __attribute__((malloc))
+#define ATTR_NONNULL(x) __attribute__((nonnull x))
+#else
+#define ATTR_NORETURN
+#define ATTR_PURE
+#define ATTR_MALLOC
+#define ATTR_NONNULL(x)
+#endif
+
 /* ===== String compatibility */
 #ifdef MS_WINDOWS
 /* Windows names string functions differently from most other platforms. */
@@ -96,10 +109,10 @@
 #define strcasecmp stricmp
 #endif
 #ifndef HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t siz);
+size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
 #endif
 #ifndef HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz);
+size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
 #endif
 
 #ifdef _MSC_VER
@@ -120,15 +133,16 @@
   size_t size;
 } tor_mmap_t;
 
-tor_mmap_t *tor_mmap_file(const char *filename);
-void tor_munmap_file(tor_mmap_t *handle);
+tor_mmap_t *tor_mmap_file(const char *filename) ATTR_NONNULL((1));
+void tor_munmap_file(tor_mmap_t *handle) ATTR_NONNULL((1));
 
 int tor_snprintf(char *str, size_t size, const char *format, ...)
-     CHECK_PRINTF(3,4);
-int tor_vsnprintf(char *str, size_t size, const char *format, va_list args);
+  CHECK_PRINTF(3,4) ATTR_NONNULL((1,3));
+int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
+  ATTR_NONNULL((1,3));
 
 const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
-                       size_t nlen);
+                       size_t nlen)  ATTR_PURE ATTR_NONNULL((1,3));
 
 #define TOR_ISALPHA(c)   isalpha((int)(unsigned char)(c))
 #define TOR_ISALNUM(c)   isalnum((int)(unsigned char)(c))
@@ -197,8 +211,8 @@
 #endif
 
 struct in_addr;
-int tor_inet_aton(const char *cp, struct in_addr *addr);
-int tor_lookup_hostname(const char *name, uint32_t *addr);
+int tor_inet_aton(const char *cp, struct in_addr *addr) ATTR_NONNULL((1,2));
+int tor_lookup_hostname(const char *name, uint32_t *addr) ATTR_NONNULL((1,2));
 void set_socket_nonblocking(int socket);
 int tor_socketpair(int family, int type, int protocol, int fd[2]);
 int network_init(void);
@@ -243,10 +257,10 @@
 /* ===== OS compatibility */
 const char *get_uname(void);
 
-uint16_t get_uint16(const char *cp);
-uint32_t get_uint32(const char *cp);
-void set_uint16(char *cp, uint16_t v);
-void set_uint32(char *cp, uint32_t v);
+uint16_t get_uint16(const char *cp) ATTR_PURE ATTR_NONNULL((1));
+uint32_t get_uint32(const char *cp) ATTR_PURE ATTR_NONNULL((1));
+void set_uint16(char *cp, uint16_t v) ATTR_NONNULL((1));
+void set_uint32(char *cp, uint32_t v) ATTR_NONNULL((1));
 
 int set_max_file_descriptors(unsigned long limit, unsigned long cap);
 int switch_id(char *user, char *group);
@@ -255,7 +269,7 @@
 #endif
 
 int spawn_func(int (*func)(void *), void *data);
-void spawn_exit(void);
+void spawn_exit(void) ATTR_NORETURN;
 
 #if defined(ENABLE_THREADS) && defined(MS_WINDOWS)
 #define USE_WIN32_THREADS

Modified: tor/trunk/src/common/container.h
===================================================================
--- tor/trunk/src/common/container.h	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/common/container.h	2006-08-11 07:09:17 UTC (rev 7020)
@@ -32,10 +32,10 @@
 void *smartlist_pop_last(smartlist_t *sl);
 void smartlist_reverse(smartlist_t *sl);
 void smartlist_string_remove(smartlist_t *sl, const char *element);
-int smartlist_isin(const smartlist_t *sl, const void *element);
-int smartlist_string_isin(const smartlist_t *sl, const char *element);
-int smartlist_string_num_isin(const smartlist_t *sl, int num);
-int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2);
+int smartlist_isin(const smartlist_t *sl, const void *element) ATTR_PURE;
+int smartlist_string_isin(const smartlist_t *sl, const char *element) ATTR_PURE;
+int smartlist_string_num_isin(const smartlist_t *sl, int num) ATTR_PURE;
+int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) ATTR_PURE;
 void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2);
 void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2);
 
@@ -43,13 +43,13 @@
 #ifdef DEBUG_SMARTLIST
 /** Return the number of items in sl.
  */
-extern INLINE int smartlist_len(const smartlist_t *sl) {
+extern INLINE int smartlist_len(const smartlist_t *sl) ATTR_PURE {
   tor_assert(sl);
   return (sl)->num_used;
 }
 /** Return the <b>idx</b>th element of sl.
  */
-extern INLINE void *smartlist_get(const smartlist_t *sl, int idx) {
+extern INLINE void *smartlist_get(const smartlist_t *sl, int idx) ATTR_PURE {
   tor_assert(sl);
   tor_assert(idx>=0);
   tor_assert(sl->num_used < idx);
@@ -75,7 +75,8 @@
 void smartlist_sort_strings(smartlist_t *sl);
 void smartlist_sort_digests(smartlist_t *sl);
 void *smartlist_bsearch(smartlist_t *sl, const void *key,
-                        int (*compare)(const void *key, const void **member));
+                        int (*compare)(const void *key, const void **member))
+ ATTR_PURE;
 
 void smartlist_pqueue_add(smartlist_t *sl,
                           int (*compare)(const void *a, const void *b),
@@ -90,9 +91,10 @@
 int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
                            int flags, int max);
 char *smartlist_join_strings(smartlist_t *sl, const char *join, int terminate,
-                             size_t *len_out);
+                             size_t *len_out) ATTR_MALLOC;
 char *smartlist_join_strings2(smartlist_t *sl, const char *join,
-                              size_t join_len, int terminate, size_t *len_out);
+                              size_t join_len, int terminate, size_t *len_out)
+  ATTR_MALLOC;
 
 /** Iterate over the items in a smartlist <b>sl</b>, in order.  For each item,
  * assign it to a new local variable of type <b>type</b> named <b>var</b>, and

Modified: tor/trunk/src/common/util.h
===================================================================
--- tor/trunk/src/common/util.h	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/common/util.h	2006-08-11 07:09:17 UTC (rev 7020)
@@ -62,12 +62,14 @@
 #define tor_fragile_assert()
 
 /* Memory management */
-void *_tor_malloc(size_t size DMALLOC_PARAMS);
-void *_tor_malloc_zero(size_t size DMALLOC_PARAMS);
+void *_tor_malloc(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
+void *_tor_malloc_zero(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
 void *_tor_realloc(void *ptr, size_t size DMALLOC_PARAMS);
-char *_tor_strdup(const char *s DMALLOC_PARAMS);
-char *_tor_strndup(const char *s, size_t n DMALLOC_PARAMS);
-void *_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS);
+char *_tor_strdup(const char *s DMALLOC_PARAMS) ATTR_MALLOC ATTR_NONNULL((1));
+char *_tor_strndup(const char *s, size_t n DMALLOC_PARAMS)
+  ATTR_MALLOC ATTR_NONNULL((1));
+void *_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS)
+  ATTR_MALLOC ATTR_NONNULL((1));
 #ifdef USE_DMALLOC
 extern int dmalloc_free(const char *file, const int line, void *pnt,
                         const int func_id);
@@ -94,15 +96,17 @@
 
 /* String manipulation */
 #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
-void tor_strlower(char *s);
-void tor_strupper(char *s);
-int tor_strisprint(const char *s);
-int tor_strisnonupper(const char *s);
-int strcmpstart(const char *s1, const char *s2);
-int strcasecmpstart(const char *s1, const char *s2);
-int strcmpend(const char *s1, const char *s2);
-int strcasecmpend(const char *s1, const char *s2);
-int tor_strstrip(char *s, const char *strip);
+void tor_strlower(char *s) ATTR_NONNULL((1));
+void tor_strupper(char *s) ATTR_NONNULL((1));
+int tor_strisprint(const char *s) ATTR_PURE ATTR_NONNULL((1));
+int tor_strisnonupper(const char *s) ATTR_PURE ATTR_NONNULL((1));
+int strcmpstart(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2));
+int strcasecmpstart(const char *s1, const char *s2)
+  ATTR_PURE ATTR_NONNULL((1,2));
+int strcmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2));
+int strcasecmpend(const char *s1, const char *s2)
+  ATTR_PURE ATTR_NONNULL((1,2));
+int tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2));
 typedef enum {
   ALWAYS_TERMINATE, NEVER_TERMINATE, TERMINATE_IF_EVEN
 } part_finish_rule_t;
@@ -115,13 +119,13 @@
                               unsigned long max, int *ok, char **next);
 uint64_t tor_parse_uint64(const char *s, int base, uint64_t min,
                          uint64_t max, int *ok, char **next);
-const char *hex_str(const char *from, size_t fromlen);
-const char *eat_whitespace(const char *s);
-const char *eat_whitespace_no_nl(const char *s);
-const char *find_whitespace(const char *s);
-int tor_mem_is_zero(const char *mem, size_t len);
-int tor_digest_is_zero(const char *digest);
-char *esc_for_log(const char *string);
+const char *hex_str(const char *from, size_t fromlen) ATTR_NONNULL((1));
+const char *eat_whitespace(const char *s) ATTR_PURE;
+const char *eat_whitespace_no_nl(const char *s) ATTR_PURE;
+const char *find_whitespace(const char *s) ATTR_PURE;
+int tor_mem_is_zero(const char *mem, size_t len) ATTR_PURE;
+int tor_digest_is_zero(const char *digest) ATTR_PURE;
+char *esc_for_log(const char *string) ATTR_MALLOC;
 const char *escaped(const char *string);
 
 void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
@@ -165,15 +169,15 @@
 int append_bytes_to_file(const char *fname, const char *str, size_t len,
                          int bin);
 
-char *read_file_to_str(const char *filename, int bin);
+char *read_file_to_str(const char *filename, int bin) ATTR_MALLOC;
 char *parse_line_from_str(char *line, char **key_out, char **value_out);
 char *expand_filename(const char *filename);
 struct smartlist_t *tor_listdir(const char *dirname);
-int path_is_relative(const char *filename);
+int path_is_relative(const char *filename) ATTR_PURE;
 
 /* Net helpers */
-int is_internal_IP(uint32_t ip, int for_listening);
-int is_local_IP(uint32_t ip);
+int is_internal_IP(uint32_t ip, int for_listening) ATTR_PURE;
+int is_local_IP(uint32_t ip) ATTR_PURE;
 int parse_addr_port(int severity, const char *addrport, char **address,
                     uint32_t *addr, uint16_t *port_out);
 int parse_port_range(const char *port, uint16_t *port_min_out,
@@ -184,7 +188,7 @@
 int addr_mask_get_bits(uint32_t mask);
 #define INET_NTOA_BUF_LEN 16
 int tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len);
-char *tor_dup_addr(uint32_t addr);
+char *tor_dup_addr(uint32_t addr) ATTR_MALLOC;
 int is_plausible_address(const char *name);
 int get_interface_address(uint32_t *addr);
 

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/or/circuitbuild.c	2006-08-11 07:09:17 UTC (rev 7020)
@@ -334,6 +334,8 @@
   return 0;
 }
 
+extern smartlist_t *circuits_pending_or_conns;
+
 /** Find any circuits that are waiting on <b>or_conn</b> to become
  * open and get them to send their create cells forward.
  *
@@ -342,7 +344,6 @@
 void
 circuit_n_conn_done(or_connection_t *or_conn, int status)
 {
-  extern smartlist_t *circuits_pending_or_conns;
   smartlist_t *changed_circs;
 
   log_debug(LD_CIRC,"or_conn to %s, status=%d",
@@ -478,8 +479,6 @@
     return 1;
 }
 
-extern int has_completed_circuit;
-
 /** This is the backbone function for building circuits.
  *
  * If circ's first hop is closed, then we need to build a create

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/or/config.c	2006-08-11 07:09:17 UTC (rev 7020)
@@ -792,7 +792,6 @@
       log_info(LD_GENERAL,
                "Worker-related options changed. Rotating workers.");
       if (server_mode(options) && !server_mode(old_options)) {
-        extern int has_completed_circuit;
         if (init_keys() < 0) {
           log_err(LD_GENERAL,"Error initializing keys; exiting");
           return -1;
@@ -1285,19 +1284,9 @@
   if (!var) {
     log_warn(LD_CONFIG, "Unknown option '%s'.  Failing.", key);
     return NULL;
-  } else if (var->type == CONFIG_TYPE_LINELIST_S) {
-    log_warn(LD_CONFIG,
-             "Can't return context-sensitive '%s' on its own", key);
-    return NULL;
   }
   value = STRUCT_VAR_P(options, var->var_offset);
 
-  if (var->type == CONFIG_TYPE_LINELIST ||
-      var->type == CONFIG_TYPE_LINELIST_V) {
-    /* Linelist requires special handling: we just copy and return it. */
-    return config_lines_dup(*(const config_line_t**)value);
-  }
-
   result = tor_malloc_zero(sizeof(config_line_t));
   result->key = tor_strdup(var->name);
   switch (var->type)
@@ -1353,6 +1342,17 @@
       tor_free(result->key);
       tor_free(result);
       return NULL;
+    case CONFIG_TYPE_LINELIST_S:
+      log_warn(LD_CONFIG,
+               "Can't return context-sensitive '%s' on its own", key);
+      tor_free(result->key);
+      tor_free(result);
+      return NULL;
+    case CONFIG_TYPE_LINELIST:
+    case CONFIG_TYPE_LINELIST_V:
+      tor_free(result->key);
+      tor_free(result);
+      return config_lines_dup(*(const config_line_t**)value);
     default:
       tor_free(result->key);
       tor_free(result);
@@ -3379,6 +3379,8 @@
         break;
       case FN_NOENT:
         break;
+      case FN_ERROR:
+      case FN_DIR:
       default:
         log_warn(LD_CONFIG,
                  "Config file \"%s\" is not a file? Failing.", fname);
@@ -3786,6 +3788,8 @@
       break;
     case FN_NOENT:
       break;
+    case FN_ERROR:
+    case FN_DIR:
     default:
       log_warn(LD_GENERAL,"State file \"%s\" is not a file? Failing.", fname);
       goto done;
@@ -3932,47 +3936,47 @@
 #include "../common/ht.h"
 #include "../common/test.h"
 
+extern const char aes_c_id[];
+extern const char compat_c_id[];
+extern const char container_c_id[];
+extern const char crypto_c_id[];
+extern const char log_c_id[];
+extern const char torgzip_c_id[];
+extern const char tortls_c_id[];
+extern const char util_c_id[];
+
+extern const char buffers_c_id[];
+extern const char circuitbuild_c_id[];
+extern const char circuitlist_c_id[];
+extern const char circuituse_c_id[];
+extern const char command_c_id[];
+//  extern const char config_c_id[];
+extern const char connection_c_id[];
+extern const char connection_edge_c_id[];
+extern const char connection_or_c_id[];
+extern const char control_c_id[];
+extern const char cpuworker_c_id[];
+extern const char directory_c_id[];
+extern const char dirserv_c_id[];
+extern const char dns_c_id[];
+extern const char hibernate_c_id[];
+extern const char main_c_id[];
+extern const char onion_c_id[];
+extern const char policies_c_id[];
+extern const char relay_c_id[];
+extern const char rendclient_c_id[];
+extern const char rendcommon_c_id[];
+extern const char rendmid_c_id[];
+extern const char rendservice_c_id[];
+extern const char rephist_c_id[];
+extern const char router_c_id[];
+extern const char routerlist_c_id[];
+extern const char routerparse_c_id[];
+
 /** Dump the version of every file to the log. */
 static void
 print_cvs_version(void)
 {
-  extern const char aes_c_id[];
-  extern const char compat_c_id[];
-  extern const char container_c_id[];
-  extern const char crypto_c_id[];
-  extern const char log_c_id[];
-  extern const char torgzip_c_id[];
-  extern const char tortls_c_id[];
-  extern const char util_c_id[];
-
-  extern const char buffers_c_id[];
-  extern const char circuitbuild_c_id[];
-  extern const char circuitlist_c_id[];
-  extern const char circuituse_c_id[];
-  extern const char command_c_id[];
-//  extern const char config_c_id[];
-  extern const char connection_c_id[];
-  extern const char connection_edge_c_id[];
-  extern const char connection_or_c_id[];
-  extern const char control_c_id[];
-  extern const char cpuworker_c_id[];
-  extern const char directory_c_id[];
-  extern const char dirserv_c_id[];
-  extern const char dns_c_id[];
-  extern const char hibernate_c_id[];
-  extern const char main_c_id[];
-  extern const char onion_c_id[];
-  extern const char policies_c_id[];
-  extern const char relay_c_id[];
-  extern const char rendclient_c_id[];
-  extern const char rendcommon_c_id[];
-  extern const char rendmid_c_id[];
-  extern const char rendservice_c_id[];
-  extern const char rephist_c_id[];
-  extern const char router_c_id[];
-  extern const char routerlist_c_id[];
-  extern const char routerparse_c_id[];
-
   puts(AES_H_ID);
   puts(COMPAT_H_ID);
   puts(CONTAINER_H_ID);

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/or/dirserv.c	2006-08-11 07:09:17 UTC (rev 7020)
@@ -455,6 +455,7 @@
     case FP_INVALID:
       ri->is_named = ri->is_valid = 0;
       break;
+    case FP_REJECT:
     default:
       tor_assert(0);
   }
@@ -1977,8 +1978,7 @@
 {
   tor_assert(conn->_base.state == DIR_CONN_STATE_SERVER_WRITING);
 
-  if (conn->dir_spool_src == DIR_SPOOL_NONE
-      || buf_datalen(conn->_base.outbuf) >= DIRSERV_BUFFER_MIN)
+  if (buf_datalen(conn->_base.outbuf) >= DIRSERV_BUFFER_MIN)
     return 0;
 
   switch (conn->dir_spool_src) {
@@ -1989,6 +1989,7 @@
       return connection_dirserv_add_dir_bytes_to_outbuf(conn);
     case DIR_SPOOL_NETWORKSTATUS:
       return connection_dirserv_add_networkstatus_bytes_to_outbuf(conn);
+    case DIR_SPOOL_NONE:
     default:
       return 0;
   }

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/or/main.c	2006-08-11 07:09:17 UTC (rev 7020)
@@ -1290,17 +1290,17 @@
   }
 }
 
+extern uint64_t buf_total_used;
+extern uint64_t buf_total_alloc;
+extern uint64_t rephist_total_alloc;
+extern uint32_t rephist_total_num;
+
 /**
  * Write current memory usage information to the log.
  */
 static void
 dumpmemusage(int severity)
 {
-  extern uint64_t buf_total_used;
-  extern uint64_t buf_total_alloc;
-  extern uint64_t rephist_total_alloc;
-  extern uint32_t rephist_total_num;
-
   log(severity, LD_GENERAL,
       "In buffers: "U64_FORMAT" used/"U64_FORMAT" allocated (%d conns).",
       U64_PRINTF_ARG(buf_total_used), U64_PRINTF_ARG(buf_total_alloc),
@@ -2143,6 +2143,7 @@
   case CMD_VERIFY_CONFIG:
     printf("Configuration was valid\n");
     break;
+  case CMD_RUN_UNITTESTS:
   default:
     log_warn(LD_BUG,"Illegal command number %d: internal error.",
              get_options()->command);

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/or/or.h	2006-08-11 07:09:17 UTC (rev 7020)
@@ -2151,6 +2151,8 @@
 
 /********************************* main.c ***************************/
 
+extern int has_completed_circuit;
+
 int connection_add(connection_t *conn);
 int connection_remove(connection_t *conn);
 int connection_in_array(connection_t *conn);

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2006-08-11 07:09:09 UTC (rev 7019)
+++ tor/trunk/src/or/test.c	2006-08-11 07:09:17 UTC (rev 7020)
@@ -937,17 +937,17 @@
   cmp = _compare_strings_for_pqueue;
 
   sl = smartlist_create();
-  smartlist_pqueue_add(sl, cmp, "cows");
-  smartlist_pqueue_add(sl, cmp, "zebras");
-  smartlist_pqueue_add(sl, cmp, "fish");
-  smartlist_pqueue_add(sl, cmp, "frogs");
-  smartlist_pqueue_add(sl, cmp, "apples");
-  smartlist_pqueue_add(sl, cmp, "squid");//
-  smartlist_pqueue_add(sl, cmp, "daschunds");
-  smartlist_pqueue_add(sl, cmp, "eggplants");
-  smartlist_pqueue_add(sl, cmp, "weissbier");//
-  smartlist_pqueue_add(sl, cmp, "lobsters");
-  smartlist_pqueue_add(sl, cmp, "roquefort");//
+  smartlist_pqueue_add(sl, cmp, (char*)"cows");
+  smartlist_pqueue_add(sl, cmp, (char*)"zebras");
+  smartlist_pqueue_add(sl, cmp, (char*)"fish");
+  smartlist_pqueue_add(sl, cmp, (char*)"frogs");
+  smartlist_pqueue_add(sl, cmp, (char*)"apples");
+  smartlist_pqueue_add(sl, cmp, (char*)"squid");
+  smartlist_pqueue_add(sl, cmp, (char*)"daschunds");
+  smartlist_pqueue_add(sl, cmp, (char*)"eggplants");
+  smartlist_pqueue_add(sl, cmp, (char*)"weissbier");
+  smartlist_pqueue_add(sl, cmp, (char*)"lobsters");
+  smartlist_pqueue_add(sl, cmp, (char*)"roquefort");
 
   OK();
 
@@ -958,9 +958,9 @@
   OK();
   test_streq(smartlist_pqueue_pop(sl, cmp), "cows");
   test_streq(smartlist_pqueue_pop(sl, cmp), "daschunds");
-  smartlist_pqueue_add(sl, cmp, "chinchillas");
+  smartlist_pqueue_add(sl, cmp, (char*)"chinchillas");
   OK();
-  smartlist_pqueue_add(sl, cmp, "fireflies");
+  smartlist_pqueue_add(sl, cmp, (char*)"fireflies");
   OK();
   test_streq(smartlist_pqueue_pop(sl, cmp), "chinchillas");
   test_streq(smartlist_pqueue_pop(sl, cmp), "eggplants");
@@ -1241,6 +1241,8 @@
   crypto_free_pk_env(pk);
 }
 
+extern smartlist_t *fingerprint_list;
+
 static void
 test_dir_format(void)
 {
@@ -1409,7 +1411,6 @@
 
   /* Okay, now for the directories. */
   {
-    extern smartlist_t *fingerprint_list;
     fingerprint_list = smartlist_create();
     crypto_pk_get_fingerprint(pk2, buf, 1);
     add_fingerprint_to_dir("Magri", buf, fingerprint_list);