summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-29 22:59:17 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-29 22:59:17 +0000
commit5c53545d8158cd486d3ccef096f895afd485dd62 (patch)
treea1d83ddbcafe741af52750b9941af42e1ac01108 /src
parentc6347cdb0ebb9ad0e374f345fbe085265caf0b15 (diff)
downloadtor-5c53545d8158cd486d3ccef096f895afd485dd62.tar.gz
tor-5c53545d8158cd486d3ccef096f895afd485dd62.zip
Add a bunch more warnings to out warning suite; resolve them; pack structs a little better.
svn:r5150
Diffstat (limited to 'src')
-rw-r--r--src/common/aes.c2
-rw-r--r--src/common/compat.c2
-rw-r--r--src/common/container.c2
-rw-r--r--src/common/crypto.c6
-rw-r--r--src/common/log.c4
-rw-r--r--src/common/tortls.c3
-rw-r--r--src/common/util.c17
-rw-r--r--src/common/util.h28
-rw-r--r--src/or/circuitbuild.c4
-rw-r--r--src/or/connection.c2
-rw-r--r--src/or/dirserv.c4
-rw-r--r--src/or/or.h37
12 files changed, 68 insertions, 43 deletions
diff --git a/src/common/aes.c b/src/common/aes.c
index d0c1a3e6cb..01f6994702 100644
--- a/src/common/aes.c
+++ b/src/common/aes.c
@@ -115,7 +115,7 @@ _aes_fill_buf(aes_cnt_cipher_t *cipher)
* Return a newly allocated counter-mode AES128 cipher implementation.
*/
aes_cnt_cipher_t*
-aes_new_cipher()
+aes_new_cipher(void)
{
aes_cnt_cipher_t* result = tor_malloc_zero(sizeof(aes_cnt_cipher_t));
diff --git a/src/common/compat.c b/src/common/compat.c
index 3718123a7f..a00c452e38 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -817,7 +817,7 @@ spawn_func(int (*func)(void *), void *data)
/** End the current thread/process.
*/
void
-spawn_exit()
+spawn_exit(void)
{
#if defined(USE_WIN32_THREADS)
_endthread();
diff --git a/src/common/container.c b/src/common/container.c
index 4c8703ca32..c9e1d63dc0 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -43,7 +43,7 @@ struct smartlist_t {
/** Allocate and return an empty smartlist.
*/
smartlist_t *
-smartlist_create() {
+smartlist_create(void) {
smartlist_t *sl = tor_malloc(sizeof(smartlist_t));
sl->num_used = 0;
sl->capacity = SMARTLIST_DEFAULT_CAPACITY;
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 50f937e703..4732241f8c 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -216,7 +216,7 @@ crypto_global_init(int useAccel)
/** Uninitialize the crypto library. Return 0 on success, -1 on failure.
*/
-int crypto_global_cleanup()
+int crypto_global_cleanup(void)
{
ERR_free_strings();
#ifndef NO_ENGINES
@@ -354,7 +354,7 @@ crypto_create_init_cipher(const char *key, int encrypt_mode)
/** Allocate and return a new symmetric cipher.
*/
-crypto_cipher_env_t *crypto_new_cipher_env()
+crypto_cipher_env_t *crypto_new_cipher_env(void)
{
crypto_cipher_env_t *env;
@@ -1303,7 +1303,7 @@ static void init_dh_param(void) {
/** Allocate and return a new DH object for a key exchange.
*/
-crypto_dh_env_t *crypto_dh_new()
+crypto_dh_env_t *crypto_dh_new(void)
{
crypto_dh_env_t *res = NULL;
diff --git a/src/common/log.c b/src/common/log.c
index e676612b6f..19c67fe2c3 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -258,7 +258,7 @@ void _log_fn(int severity, const char *format, ...)
#endif
/** Close all open log files. */
-void close_logs()
+void close_logs(void)
{
logfile_t *victim;
while (logfiles) {
@@ -271,7 +271,7 @@ void close_logs()
}
/** Close and re-open all log files; used to rotate logs on SIGHUP. */
-void reset_logs()
+void reset_logs(void)
{
logfile_t *lf = logfiles;
while (lf) {
diff --git a/src/common/tortls.c b/src/common/tortls.c
index f88c99d6df..37ab9d1cc6 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -177,6 +177,9 @@ tor_tls_free_all(void)
static int always_accept_verify_cb(int preverify_ok,
X509_STORE_CTX *x509_ctx)
{
+ /* avoid "unused parameter" warning. */
+ preverify_ok = 0;
+ x509_ctx = NULL;
return 1;
}
diff --git a/src/common/util.c b/src/common/util.c
index dd02661718..f2ddc27993 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -96,6 +96,7 @@ const char util_c_id[] = "$Id$";
* ===== */
#ifdef USE_DMALLOC
#include <dmalloc.h>
+ #define DMALLOC_FN_ARGS file, line,
#else
#define dmalloc_strdup(file, line, string, xalloc_b) strdup(string)
@@ -104,6 +105,7 @@ const char util_c_id[] = "$Id$";
#define dmalloc_realloc(file, line, old_pnt, new_size, func_id, xalloc_b) realloc((old_pnt), (new_size))
#define DMALLOC_FUNC_REALLOC 0
+ #define DMALLOC_FN_ARGS
#endif
/** Allocate a chunk of <b>size</b> bytes of memory, and return a pointer to
@@ -113,7 +115,8 @@ const char util_c_id[] = "$Id$";
* <b>file</b> and <b>line</b> are used if dmalloc is enabled, and
* ignored otherwise.
*/
-void *_tor_malloc(const char *file, const int line, size_t size) {
+void *_tor_malloc(DMALLOC_PARAMS size_t size)
+{
void *result;
/* Some libcs don't do the right thing on size==0. Override them. */
@@ -136,8 +139,8 @@ void *_tor_malloc(const char *file, const int line, size_t size) {
* zero bytes, and return a pointer to the result. Log and terminate
* the process on error. (Same as calloc(size,1), but never returns NULL.)
*/
-void *_tor_malloc_zero(const char *file, const int line, size_t size) {
- void *result = _tor_malloc(file, line, size);
+void *_tor_malloc_zero(DMALLOC_PARAMS size_t size) {
+ void *result = _tor_malloc(DMALLOC_FN_ARGS size);
memset(result, 0, size);
return result;
}
@@ -146,7 +149,7 @@ void *_tor_malloc_zero(const char *file, const int line, size_t size) {
* bytes long; return the new memory block. On error, log and
* terminate. (Like realloc(ptr,size), but never returns NULL.)
*/
-void *_tor_realloc(const char *file, const int line, void *ptr, size_t size) {
+void *_tor_realloc(DMALLOC_PARAMS void *ptr, size_t size) {
void *result;
result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0);
@@ -161,7 +164,7 @@ void *_tor_realloc(const char *file, const int line, void *ptr, size_t size) {
* error, log and terminate. (Like strdup(s), but never returns
* NULL.)
*/
-char *_tor_strdup(const char *file, const int line, const char *s) {
+char *_tor_strdup(DMALLOC_PARAMS const char *s) {
char *dup;
tor_assert(s);
@@ -179,10 +182,10 @@ char *_tor_strdup(const char *file, const int line, const char *s) {
* always NUL-terminated. (Like strndup(s,n), but never returns
* NULL.)
*/
-char *_tor_strndup(const char *file, const int line, const char *s, size_t n) {
+char *_tor_strndup(DMALLOC_PARAMS const char *s, size_t n) {
char *dup;
tor_assert(s);
- dup = _tor_malloc(file, line, n+1);
+ dup = _tor_malloc(DMALLOC_FN_ARGS n+1);
/* Performance note: Ordinarily we prefer strlcpy to strncpy. But
* this function gets called a whole lot, and platform strncpy is
* much faster than strlcpy when strlen(s) is much longer than n.
diff --git a/src/common/util.h b/src/common/util.h
index 791b023e25..c4227b6d13 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -47,24 +47,32 @@
} } while (0)
#endif
+#ifdef USE_DMALLOC
+#define DMALLOC_PARAMS const char *file, const int line,
+#define DMALLOC_ARGS _SHORT_FILE_, __LINE__,
+#else
+#define DMALLOC_PARAMS
+#define DMALLOC_ARGS
+#endif
+
/** Define this if you want Tor to crash when any problem comes up,
* so you can get a coredump and track things down. */
// #define tor_fragile_assert() tor_assert(0)
#define tor_fragile_assert()
/* Memory management */
-void *_tor_malloc(const char *file, const int line, size_t size);
-void *_tor_malloc_zero(const char *file, const int line, size_t size);
-void *_tor_realloc(const char *file, const int line, void *ptr, size_t size);
-char *_tor_strdup(const char *file, const int line, const char *s);
-char *_tor_strndup(const char *file, const int line, const char *s, size_t n);
+void *_tor_malloc(DMALLOC_PARAMS size_t size);
+void *_tor_malloc_zero(DMALLOC_PARAMS size_t size);
+void *_tor_realloc(DMALLOC_PARAMS void *ptr, size_t size);
+char *_tor_strdup(DMALLOC_PARAMS const char *s);
+char *_tor_strndup(DMALLOC_PARAMS const char *s, size_t n);
#define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0)
-#define tor_malloc(size) _tor_malloc(_SHORT_FILE_, __LINE__, size)
-#define tor_malloc_zero(size) _tor_malloc_zero(_SHORT_FILE_, __LINE__, size)
-#define tor_realloc(ptr, size) _tor_realloc(_SHORT_FILE_, __LINE__, ptr, size)
-#define tor_strdup(s) _tor_strdup(_SHORT_FILE_, __LINE__, s)
-#define tor_strndup(s, n) _tor_strndup(_SHORT_FILE_, __LINE__, s, n)
+#define tor_malloc(size) _tor_malloc(DMALLOC_ARGS size)
+#define tor_malloc_zero(size) _tor_malloc_zero(DMALLOC_ARGS size)
+#define tor_realloc(ptr, size) _tor_realloc(DMALLOC_ARGS ptr, size)
+#define tor_strdup(s) _tor_strdup(DMALLOC_ARGS s)
+#define tor_strndup(s, n) _tor_strndup(DMALLOC_ARGS s, n)
/* String manipulation */
#define HEX_CHARACTERS "0123456789ABCDEFabcdef"
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 6ccdd47086..d488fbe127 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -979,6 +979,8 @@ circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
uint16_t *port;
smartlist_t *sl = circuit_get_unhandled_ports(now);
smartlist_t *LongLivedServices = get_options()->LongLivedPorts;
+ tor_assert(need_uptime);
+ tor_assert(need_capacity);
enough = (smartlist_len(sl) == 0);
for (i = 0; i < smartlist_len(sl); ++i) {
port = smartlist_get(sl, i);
@@ -1380,6 +1382,8 @@ choose_good_middle_server(uint8_t purpose,
routerinfo_t *r, *choice;
crypt_path_t *cpath;
smartlist_t *excluded;
+ tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
+ purpose <= _CIRCUIT_PURPOSE_MAX);
log_fn(LOG_DEBUG, "Contemplating intermediate hop: random choice.");
excluded = smartlist_create();
diff --git a/src/or/connection.c b/src/or/connection.c
index e4d913965b..d94fb0feb7 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -2000,8 +2000,10 @@ assert_connection_ok(connection_t *conn, time_t now)
tor_assert(!conn->cpath_layer);
tor_assert(!conn->package_window);
tor_assert(!conn->deliver_window);
+#if 0
tor_assert(!conn->done_sending);
tor_assert(!conn->done_receiving);
+#endif
} else {
/* XXX unchecked: package window, deliver window. */
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 0a9b9ab78e..a20b09315a 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -303,7 +303,7 @@ dirserv_get_nickname_by_digest(const char *digest)
/** Clear the current fingerprint list. */
void
-dirserv_free_fingerprint_list()
+dirserv_free_fingerprint_list(void)
{
int i;
fingerprint_entry_t *ent;
@@ -555,7 +555,7 @@ dirserver_getinfo_unregistered(const char *question)
* generated one.
*/
void
-directory_set_dirty()
+directory_set_dirty(void)
{
time_t now = time(NULL);
diff --git a/src/or/or.h b/src/or/or.h
index 4234765465..2c85de4f01 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -591,24 +591,29 @@ struct connection_t {
uint8_t type; /**< What kind of connection is this? */
uint8_t state; /**< Current state of this connection. */
uint8_t purpose; /**< Only used for DIR types currently. */
- uint8_t wants_to_read; /**< Boolean: should we start reading again once
- * the bandwidth throttler allows it?
- */
- uint8_t wants_to_write; /**< Boolean: should we start writing again once
- * the bandwidth throttler allows reads?
- */
+ unsigned wants_to_read:1; /**< Boolean: should we start reading again once
+ * the bandwidth throttler allows it?
+ */
+ unsigned wants_to_write:1; /**< Boolean: should we start writing again once
+ * the bandwidth throttler allows reads?
+ */
+ unsigned marked_for_close:1; /**< Boolean: should we close this conn on the
+ * next iteration of the main loop?
+ */
+ unsigned hold_open_until_flushed:1; /**< Despite this connection's being
+ * marked for close, do we flush it
+ * before closing it?
+ */
+ unsigned has_sent_end:1; /**< For debugging; only used on edge connections.
+ * Set once we've set the stream end,
+ * and check in circuit_about_to_close_connection(). */
+
int s; /**< Our socket; -1 if this connection is closed. */
int poll_index; /* XXXX rename. */
struct event *read_event; /**< libevent event structure. */
struct event *write_event; /**< libevent event structure. */
- int marked_for_close; /**< Boolean: should we close this conn on the next
- * iteration of the main loop?
- */
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?
- */
buf_t *inbuf; /**< Buffer holding data read over this connection. */
int inbuf_reached_eof; /**< Boolean: did read() return 0 on this conn? */
@@ -668,10 +673,10 @@ struct connection_t {
int deliver_window; /**< How many more relay cells can end at me? (Edge
* only.) */
+#if 0
int done_sending; /**< For half-open connections; not used currently. */
int done_receiving; /**< For half-open connections; not used currently. */
- char has_sent_end; /**< For debugging: set once we've set the stream end,
- and check in circuit_about_to_close_connection(). */
+#endif
struct circuit_t *on_circuit; /**< The circuit (if any) that this edge
* connection is using. */
@@ -805,9 +810,9 @@ typedef struct routerstatus_t {
/** DOCDOC */
typedef struct local_routerstatus_t {
routerstatus_t status;
+ time_t next_attempt_at; /**< When should we try this descriptor again? */
uint8_t n_download_failures; /**< Number of failures trying to download the
* most recent descriptor. */
- time_t next_attempt_at; /**< When should we try this descriptor again? */
unsigned int should_download:1; /**< DOCDOC */
} local_routerstatus_t;
@@ -1101,9 +1106,9 @@ typedef struct exit_redirect_t {
uint16_t port_min;
uint16_t port_max;
- int is_redirect;
uint32_t addr_dest;
uint16_t port_dest;
+ unsigned is_redirect:1;
} exit_redirect_t;
typedef struct config_line_t {