[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Remove false warnings from printf checks
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv2108/src/common
Modified Files:
log.c log.h
Log Message:
Remove false warnings from printf checks
Index: log.c
===================================================================
RCS file: /home/or/cvsroot/src/common/log.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- log.c 17 Jun 2003 21:36:44 -0000 1.6
+++ log.c 21 Jun 2003 19:03:22 -0000 1.7
@@ -42,33 +42,36 @@
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 */
Index: log.h
===================================================================
RCS file: /home/or/cvsroot/src/common/log.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- log.h 17 Jun 2003 22:14:44 -0000 1.9
+++ log.h 21 Jun 2003 19:03:22 -0000 1.10
@@ -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);