[or-cvs] some early bugfixes

Roger Dingledine arma at seul.org
Tue Oct 7 16:30:30 UTC 2003


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	log.c log.h util.c util.h 
Log Message:
some early bugfixes

our log() conflicts with log(3)
distribute only the correct files from doc/ and src/config/
sometimes laptops go back in time. i guess that's ok for now.
and bump the version number because we're live.






Index: log.c
===================================================================
RCS file: /home/or/cvsroot/src/common/log.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- log.c	4 Oct 2003 03:29:07 -0000	1.20
+++ log.c	7 Oct 2003 16:29:57 -0000	1.21
@@ -103,7 +103,7 @@
 }
 
 /* Outputs a message to stdout */
-void log(int severity, const char *format, ...)
+void _log(int severity, const char *format, ...)
 {
   va_list ap;
   va_start(ap,format);

Index: log.h
===================================================================
RCS file: /home/or/cvsroot/src/common/log.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- log.h	16 Sep 2003 17:58:36 -0000	1.14
+++ log.h	7 Oct 2003 16:29:57 -0000	1.15
@@ -36,7 +36,7 @@
 void reset_logs();
 
 /* Outputs a message to stdout */
-void log(int severity, const char *format, ...) CHECK_PRINTF(2,3);
+void _log(int severity, const char *format, ...) CHECK_PRINTF(2,3);
 
 #ifdef __GNUC__
 void _log_fn(int severity, const char *funcname, const char *format, ...)
@@ -44,8 +44,9 @@
 #define log_fn(severity, args...) \
   _log_fn(severity, __PRETTY_FUNCTION__, args)
 #else
-#define log_fn log
+#define log_fn _log
 #endif
+#define log _log /* hack it so we don't conflict with log() as much */
 
 # define __LOG_H
 #endif

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- util.c	4 Oct 2003 03:29:07 -0000	1.26
+++ util.c	7 Oct 2003 16:29:57 -0000	1.27
@@ -61,7 +61,6 @@
 tv_udiff(struct timeval *start, struct timeval *end)
 {
   long udiff;
-  long end_usec = end->tv_usec;
   long secdiff = end->tv_sec - start->tv_sec;
 
   if (secdiff+1 > LONG_MAX/1000000) {
@@ -69,9 +68,10 @@
     return LONG_MAX;
   }
 
-  udiff = secdiff*1000000L + (end_usec - start->tv_usec);
+  udiff = secdiff*1000000L + (end->tv_usec - start->tv_usec);
   if(udiff < 0) {
-    log_fn(LOG_WARNING, "start is after end. Returning 0.");
+    log_fn(LOG_INFO, "start (%ld.%ld) is after end (%ld.%ld). Returning 0.",
+           start->tv_sec, start->tv_usec, end->tv_sec, end->tv_usec);
     return 0;
   }
   return udiff;

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- util.h	4 Oct 2003 03:29:07 -0000	1.16
+++ util.h	7 Oct 2003 16:29:57 -0000	1.17
@@ -32,6 +32,7 @@
 #define INLINE inline
 #endif
 
+#define xfree(p) do {if(p) {free(p); (p)=NULL;}} while(0) /* XXX use everywhere? */
 void *tor_malloc(size_t size);
 char *tor_strdup(const char *s);
 void tor_gettimeofday(struct timeval *timeval);



More information about the tor-commits mailing list