summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-06-21 19:03:22 +0000
committerNick Mathewson <nickm@torproject.org>2003-06-21 19:03:22 +0000
commitefbcd71b9ba03c7f931b2c66a3e1b91c5f6d3eeb (patch)
tree825ddc8643dd1fabf34cb390b2d49ef7ca07aa88
parent49f082fcee43d23a3f25b92d1c3f1ce4c235cd21 (diff)
downloadtor-efbcd71b9ba03c7f931b2c66a3e1b91c5f6d3eeb.tar.gz
tor-efbcd71b9ba03c7f931b2c66a3e1b91c5f6d3eeb.zip
Remove false warnings from printf checks
svn:r340
-rw-r--r--src/common/log.c39
-rw-r--r--src/common/log.h2
-rw-r--r--src/or/circuit.c2
-rw-r--r--src/or/main.c2
-rw-r--r--src/or/onion.c2
-rw-r--r--src/or/test.c2
6 files changed, 27 insertions, 22 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 92c0b3781e..12785d8704 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -42,33 +42,36 @@ size_t sev_to_string(char *buf, int max, int severity) {
return strlen(buf)+1;
}
+static int loglevel = LOG_DEBUG;
+
static void
logv(int severity, const char *funcname, const char *format, va_list ap)
{
- static int loglevel = LOG_DEBUG;
char buf[201];
time_t t;
struct timeval now;
- if (format) {
-
- if (severity > loglevel)
- return;
- if (gettimeofday(&now,NULL) < 0)
- return;
+ assert(format);
+ if (severity > loglevel)
+ return;
+ if (gettimeofday(&now,NULL) < 0)
+ return;
- t = time(NULL);
- strftime(buf, 200, "%b %d %H:%M:%S", localtime(&t));
- printf("%s.%.3ld ", buf, (long)now.tv_usec / 1000);
- sev_to_string(buf, 200, severity);
- printf("[%s] ", buf);
- if (funcname)
- printf("%s(): ", funcname);
- vprintf(format,ap);
- printf("\n");
- } else
- loglevel = severity;
+ t = time(NULL);
+ strftime(buf, 200, "%b %d %H:%M:%S", localtime(&t));
+ printf("%s.%.3ld ", buf, (long)now.tv_usec / 1000);
+ sev_to_string(buf, 200, severity);
+ printf("[%s] ", buf);
+ if (funcname)
+ printf("%s(): ", funcname);
+ vprintf(format,ap);
+ printf("\n");
+}
+void
+log_set_severity(int severity)
+{
+ loglevel = severity;
}
/* Outputs a message to stdout */
diff --git a/src/common/log.h b/src/common/log.h
index 0cf7c0dd6d..2d77009ad1 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -17,6 +17,8 @@
#define CHECK_PRINTF(formatIdx, firstArg)
#endif
+void log_set_severity(int severity);
+
/* Outputs a message to stdout and also logs the same message using syslog. */
void log(int severity, const char *format, ...) CHECK_PRINTF(2,3);
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 6b593f9c4a..f39cb367ab 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -473,7 +473,7 @@ void circuit_close(circuit_t *circ) {
assert(circ);
if(options.APPort) {
youngest = circuit_get_newest_ap();
- log_fn(LOG_DEBUG,"youngest %d, circ %d.",youngest, (int)circ);
+ log_fn(LOG_DEBUG,"youngest %d, circ %d.",(int)youngest, (int)circ);
}
circuit_remove(circ);
if(circ->n_conn)
diff --git a/src/or/main.c b/src/or/main.c
index f81cf5d45c..bc1e65e4c4 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -792,7 +792,7 @@ int tor_main(int argc, char *argv[]) {
if(getconfig(argc,argv,&options))
exit(1);
- log(options.loglevel,NULL); /* assign logging severity level from options */
+ log_set_severity(options.loglevel); /* assign logging severity level from options */
if(options.Daemon)
daemonize();
diff --git a/src/or/onion.c b/src/or/onion.c
index e71e308d9e..9cf3041e34 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -329,7 +329,7 @@ crypt_path_t *onion_generate_cpath(routerinfo_t **firsthop) {
log(LOG_DEBUG,"onion_generate_cpath(): %u : %s:%u, %u/%u",routelen-i,
inet_ntoa(netaddr),
(rarray[route[i]])->or_port,
- (rarray[route[i]])->pkey,
+ (int) (rarray[route[i]])->pkey,
crypto_pk_keysize((rarray[route[i]])->pkey));
}
diff --git a/src/or/test.c b/src/or/test.c
index e956961127..ab403fc1c9 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -594,7 +594,7 @@ main(int c, char**v){
if(getconfig(c,v,&options))
exit(1);
#endif
- log(LOG_ERR,NULL); /* make logging quieter */
+ log_set_severity(LOG_ERR); /* make logging quieter */
crypto_seed_rng();