applog - force type checking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
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, ...);