Browse Source

Add printf-format syntax checks to more functions that should use it

Luke Dashjr 12 years ago
parent
commit
7d8f121a5f
6 changed files with 15 additions and 10 deletions
  1. 2 0
      driver-modminer.c
  2. 0 2
      driver-opencl.c
  3. 3 1
      logging.c
  4. 5 5
      logging.h
  5. 2 0
      miner.c
  6. 3 2
      miner.h

+ 2 - 0
driver-modminer.c

@@ -50,6 +50,8 @@ struct modminer_fpga_state {
 	unsigned char pdone;
 };
 
+static inline bool _bailout(int fd, struct cgpu_info*modminer, int prio, const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 4, 5);
+
 static inline bool
 _bailout(int fd, struct cgpu_info*modminer, int prio, const char *fmt, ...)
 {

+ 0 - 2
driver-opencl.c

@@ -271,8 +271,6 @@ extern bool have_opencl;
 
 extern void *miner_thread(void *userdata);
 extern int dev_from_id(int thr_id);
-extern void tailsprintf(char *f, const char *fmt, ...);
-extern void wlog(const char *f, ...);
 extern void decay_time(double *f, double fadd);
 
 

+ 3 - 1
logging.c

@@ -21,6 +21,8 @@ bool opt_log_output = false;
 /* per default priorities higher than LOG_NOTICE are logged */
 int opt_log_level = LOG_NOTICE;
 
+static void my_log_curses(int prio, char *f, va_list ap) FORMAT_SYNTAX_CHECK(printf, 2, 0);
+
 static void my_log_curses(__maybe_unused int prio, char *f, va_list ap)
 {
 	if (opt_quiet && prio != LOG_ERR)
@@ -48,7 +50,7 @@ static void my_log_curses(__maybe_unused int prio, char *f, va_list ap)
 	}
 }
 
-static void log_generic(int prio, const char *fmt, va_list ap);
+static void log_generic(int prio, const char *fmt, va_list ap) FORMAT_SYNTAX_CHECK(printf, 2, 0);
 
 void vapplog(int prio, const char *fmt, va_list ap)
 {

+ 5 - 5
logging.h

@@ -32,10 +32,10 @@ extern void vapplog(int prio, const char *fmt, va_list ap) FORMAT_SYNTAX_CHECK(p
 extern void applog(int prio, const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 2, 3);
 
 /* high-level logging functions with implicit priority */
-extern void log_error(const char *fmt, ...);
-extern void log_warning(const char *fmt, ...);
-extern void log_notice(const char *fmt, ...);
-extern void log_info(const char *fmt, ...);
-extern void log_debug(const char *fmt, ...);
+extern void log_error(const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
+extern void log_warning(const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
+extern void log_notice(const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
+extern void log_info(const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
+extern void log_debug(const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
 
 #endif /* __LOGGING_H__ */

+ 2 - 0
miner.c

@@ -380,6 +380,8 @@ void get_timestamp(char *f, struct timeval *tv)
 		tm->tm_sec);
 }
 
+static void applog_and_exit(const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
+
 static void applog_and_exit(const char *fmt, ...)
 {
 	va_list ap;

+ 3 - 2
miner.h

@@ -1069,8 +1069,9 @@ extern enum test_nonce2_result _test_nonce2(struct work *, uint32_t nonce, bool
 #define test_nonce(work, nonce, checktarget)  (_test_nonce2(work, nonce, checktarget) == TNR_GOOD)
 #define test_nonce2(work, nonce)  (_test_nonce2(work, nonce, true))
 bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
-extern void tailsprintf(char *f, const char *fmt, ...);
-extern void wlogprint(const char *f, ...);
+extern void tailsprintf(char *f, const char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 2, 3);
+extern void wlog(const char *f, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
+extern void wlogprint(const char *f, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
 extern int curses_int(const char *query);
 extern char *curses_input(const char *query);
 extern void kill_work(void);