diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-08-11 07:09:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-08-11 07:09:17 +0000 |
commit | 09a895e222f446d400337a3b65b8563705364ec0 (patch) | |
tree | 28329a7eeb802fe270e7a3bde2aaf26ff0de2f3d | |
parent | b07525d316c6121d86bb8fa9664326f9b160604c (diff) | |
download | tor-09a895e222f446d400337a3b65b8563705364ec0.tar tor-09a895e222f446d400337a3b65b8563705364ec0.tar.gz |
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.
svn:r7020
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/common/compat.h | 42 | ||||
-rw-r--r-- | src/common/container.h | 20 | ||||
-rw-r--r-- | src/common/util.h | 56 | ||||
-rw-r--r-- | src/or/circuitbuild.c | 5 | ||||
-rw-r--r-- | src/or/config.c | 100 | ||||
-rw-r--r-- | src/or/dirserv.c | 5 | ||||
-rw-r--r-- | src/or/main.c | 11 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/test.c | 29 |
10 files changed, 150 insertions, 122 deletions
diff --git a/configure.in b/configure.in index 8ee912849..0967a8a8d 100644 --- a/configure.in +++ b/configure.in @@ -645,7 +645,7 @@ else 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" diff --git a/src/common/compat.h b/src/common/compat.h index 1b96c1a5c..853bcd0a0 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -89,6 +89,19 @@ extern INLINE double U64_TO_DBL(uint64_t x) { #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 @@ extern INLINE double U64_TO_DBL(uint64_t x) { #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 @@ typedef struct tor_mmap_t { 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 @@ typedef int socklen_t; #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 @@ const char *tor_socket_strerror(int e); /* ===== 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 @@ char *get_user_homedir(const char *username); #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 diff --git a/src/common/container.h b/src/common/container.h index 85072e644..6e266fead 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -32,10 +32,10 @@ void smartlist_remove(smartlist_t *sl, const void *element); 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 @@ void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2); #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(smartlist_t *sl, 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 @@ void smartlist_pqueue_assert_ok(smartlist_t *sl, 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 diff --git a/src/common/util.h b/src/common/util.h index fb1534469..7c0cc1c5a 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -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 @@ extern int dmalloc_free(const char *file, const int line, void *pnt, /* 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 tor_parse_ulong(const char *s, int base, unsigned long min, 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 write_chunks_to_file(const char *fname, const struct smartlist_t *chunks, 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 parse_addr_and_port_range(const char *s, uint32_t *addr_out, 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); diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index fa5da30c4..2e0438ad6 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -334,6 +334,8 @@ circuit_handle_first_hop(origin_circuit_t *circ) 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 @@ circuit_handle_first_hop(origin_circuit_t *circ) 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 @@ should_use_create_fast_for_router(routerinfo_t *router) 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 diff --git a/src/or/config.c b/src/or/config.c index 560428f4d..01623bb46 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -792,7 +792,6 @@ options_act(or_options_t *old_options) 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 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, 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 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, 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 @@ write_configuration_file(const char *fname, or_options_t *options) 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 @@ or_state_load(void) 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 @@ config_getinfo_helper(const char *question, char **answer) #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); diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 6a07d3ca5..ea8a0b512 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -455,6 +455,7 @@ authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg, case FP_INVALID: ri->is_named = ri->is_valid = 0; break; + case FP_REJECT: default: tor_assert(0); } @@ -1977,8 +1978,7 @@ connection_dirserv_flushed_some(dir_connection_t *conn) { 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 @@ connection_dirserv_flushed_some(dir_connection_t *conn) 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; } diff --git a/src/or/main.c b/src/or/main.c index 4370dcbc1..9c34e325b 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1290,17 +1290,17 @@ signal_callback(int fd, short events, void *arg) } } +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 @@ tor_main(int argc, char *argv[]) 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); diff --git a/src/or/or.h b/src/or/or.h index a984819cf..fc2d3063a 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2151,6 +2151,8 @@ void accounting_set_bandwidth_usage_from_state(or_state_t *state); /********************************* 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); diff --git a/src/or/test.c b/src/or/test.c index fa342d629..536927639 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -937,17 +937,17 @@ test_pqueue(void) 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 @@ test_pqueue(void) 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 @@ test_onion_handshake(void) crypto_free_pk_env(pk); } +extern smartlist_t *fingerprint_list; + static void test_dir_format(void) { @@ -1409,7 +1411,6 @@ test_dir_format(void) /* 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); |