aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-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
8 files changed, 39 insertions, 25 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"