Commit 8f08a327ca94e3f88216bc8229f5ba96bc1cae44

Kano 2013-05-02T22:50:25

applog - force type checking

diff --git a/cgminer.c b/cgminer.c
index 74012f6..82b851c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6487,10 +6487,14 @@ static void clean_up(void)
 
 void quit(int status, const char *format, ...)
 {
-	clean_up();
+	if (format) {
+		va_list ap;
+		va_start(ap, format);
+		vapplog(LOG_ERR, format, ap);
+		va_end(ap);
+	}
 
-	if (format)
-		log_error(format);
+	clean_up();
 
 #if defined(unix)
 	if (forkpid > 0) {
diff --git a/logging.c b/logging.c
index 309d13c..45d80bf 100644
--- a/logging.c
+++ b/logging.c
@@ -53,7 +53,7 @@ void vapplog(int prio, const char *fmt, va_list ap)
 		log_generic(prio, fmt, ap);
 }
 
-void applog(int prio, const char *fmt, ...)
+void _applog(int prio, const char *fmt, ...)
 {
 	va_list ap;
 
diff --git a/logging.h b/logging.h
index 52f9873..be3923f 100644
--- a/logging.h
+++ b/logging.h
@@ -28,7 +28,14 @@ extern int opt_log_level;
 
 /* low-level logging functions with priority parameter */
 extern void vapplog(int prio, const char *fmt, va_list ap);
-extern void applog(int prio, const char *fmt, ...);
+extern void _applog(int prio, const char *fmt, ...);
+#define applog(prio, fmt, ...) do { \
+ char *tmp42; \
+ if (0) \
+	sprintf(tmp42, fmt, ##__VA_ARGS__); \
+ else \
+	_applog(prio, fmt, ##__VA_ARGS__); \
+} while (0)
 
 /* high-level logging functions with implicit priority */
 extern void log_error(const char *fmt, ...);