[or-cvs] Add a bunch more warnings to out warning suite; resolve the...

Nick Mathewson nickm at seul.org
Thu Sep 29 22:59:19 UTC 2005


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv4516/common

Modified Files:
	aes.c compat.c container.c crypto.c log.c tortls.c util.c 
	util.h 
Log Message:
Add a bunch more warnings to out warning suite; resolve them; pack structs a little better.

Index: aes.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/aes.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- aes.c	27 Sep 2005 19:39:25 -0000	1.25
+++ aes.c	29 Sep 2005 22:59:17 -0000	1.26
@@ -115,7 +115,7 @@
  * 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));
 

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- compat.c	14 Sep 2005 23:27:52 -0000	1.68
+++ compat.c	29 Sep 2005 22:59:17 -0000	1.69
@@ -817,7 +817,7 @@
 /** End the current thread/process.
  */
 void
-spawn_exit()
+spawn_exit(void)
 {
 #if defined(USE_WIN32_THREADS)
   _endthread();

Index: container.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- container.c	18 Sep 2005 02:17:02 -0000	1.39
+++ container.c	29 Sep 2005 22:59:17 -0000	1.40
@@ -43,7 +43,7 @@
 /** 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;

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- crypto.c	18 Sep 2005 02:18:59 -0000	1.156
+++ crypto.c	29 Sep 2005 22:59:17 -0000	1.157
@@ -216,7 +216,7 @@
 
 /** 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 @@
 
 /** 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 @@
 
 /** 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;
 

Index: log.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- log.c	12 Aug 2005 17:24:53 -0000	1.98
+++ log.c	29 Sep 2005 22:59:17 -0000	1.99
@@ -258,7 +258,7 @@
 #endif
 
 /** Close all open log files. */
-void close_logs()
+void close_logs(void)
 {
   logfile_t *victim;
   while (logfiles) {
@@ -271,7 +271,7 @@
 }
 
 /** 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) {

Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/tortls.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- tortls.c	26 Aug 2005 18:40:44 -0000	1.101
+++ tortls.c	29 Sep 2005 22:59:17 -0000	1.102
@@ -177,6 +177,9 @@
 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;
 }
 

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -d -r1.223 -r1.224
--- util.c	13 Sep 2005 06:19:31 -0000	1.223
+++ util.c	29 Sep 2005 22:59:17 -0000	1.224
@@ -96,6 +96,7 @@
  * ===== */
 #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 @@
 
  #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 @@
  * <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 @@
  * 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 @@
  * 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 @@
  * 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 @@
  * 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.

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.h,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- util.h	13 Sep 2005 06:19:31 -0000	1.139
+++ util.h	29 Sep 2005 22:59:17 -0000	1.140
@@ -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"



More information about the tor-commits mailing list