]> mj.ucw.cz Git - libucw.git/commitdiff
Added more format string checks.
authorMartin Mares <mj@ucw.cz>
Fri, 17 Jun 2005 21:01:28 +0000 (21:01 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 17 Jun 2005 21:01:28 +0000 (21:01 +0000)
lib/fastbuf.h
lib/ff-printf.c
lib/lib.h
lib/mempool.h
lib/stkstring.h

index ea71f1206a38c2e40f915d14db7b44c155ec275a..905d046d134689c2a86a2a795dd7d46a56280abc 100644 (file)
@@ -411,7 +411,7 @@ bdirect_write_commit(struct fastbuf *f, byte *pos)
 
 /* Formatted output */
 
-int bprintf(struct fastbuf *b, byte *msg, ...);
-int vbprintf(struct fastbuf *b, byte *msg, va_list args);
+int bprintf(struct fastbuf *b, char *msg, ...) FORMAT_CHECK(printf,2,3);
+int vbprintf(struct fastbuf *b, char *msg, va_list args);
 
 #endif
index cac06b55d907de387df3e6090451a136e9c98d72..fe9c964283d2a0e6e1eff67b90fd3420e89014b7 100644 (file)
@@ -13,7 +13,7 @@
 #include <alloca.h>
 
 int
-vbprintf(struct fastbuf *b, byte *msg, va_list args)
+vbprintf(struct fastbuf *b, char *msg, va_list args)
 {
   byte *buf;
   int len, r;
@@ -52,7 +52,7 @@ vbprintf(struct fastbuf *b, byte *msg, va_list args)
 }
 
 int
-bprintf(struct fastbuf *b, byte *msg, ...)
+bprintf(struct fastbuf *b, char *msg, ...)
 {
   va_list args;
   int res;
index edb16e0f6e42358240d13df064f76715023254c9..00772320648f2ae866f1dfa59d4daffcaac727e0 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -53,6 +53,7 @@
 #define PACKED __attribute__((packed))
 #define CONST __attribute__((const))
 #define PURE __attribute__((const))
+#define FORMAT_CHECK(x,y,z) __attribute__((format(x,y,z)))
 #define likely(x) __builtin_expect((x),1)
 #define unlikely(x) __builtin_expect((x),0)
 
@@ -79,10 +80,10 @@ extern void (*log_die_hook)(void);
 struct tm;
 extern void (*log_switch_hook)(struct tm *tm);
 
-void log_msg(unsigned int cat, const char *msg, ...) __attribute__((format(printf,2,3)));
+void log_msg(unsigned int cat, const char *msg, ...) FORMAT_CHECK(printf,2,3);
 #define log log_msg
 void vlog_msg(unsigned int cat, const char *msg, va_list args);
-void die(const char *, ...) NONRET __attribute__((format(printf,1,2)));
+void die(const char *, ...) NONRET FORMAT_CHECK(printf,1,2);
 void log_init(byte *argv0);
 void log_file(byte *name);
 void log_fork(void);
@@ -204,7 +205,7 @@ sh_off_t partmap_size(struct partmap *p);
 /* proctitle.c */
 
 void setproctitle_init(int argc, char **argv);
-void setproctitle(char *msg, ...) __attribute__((format(printf,1,2)));
+void setproctitle(char *msg, ...) FORMAT_CHECK(printf,1,2);
 
 /* randomkey.c */
 
index 98d46e57d620bdb8f4cb03816c90eec556f83eb5..255e5389fd8431d7974fe32af8046eb261dbc9a1 100644 (file)
@@ -72,7 +72,7 @@ mp_strcat(struct mempool *mp, char *x, char *y)
 
 /* mempool-fmt.c */
 
-char *mp_printf(struct mempool *p, char *fmt, ...);
+char *mp_printf(struct mempool *p, char *fmt, ...) FORMAT_CHECK(printf,2,3);
 char *mp_vprintf(struct mempool *p, char *fmt, va_list args);
 
 #endif
index 735d63e280fe0292d12f5f70e40d88ca3dcafaf6..03f68904692ffe4cb1344b003c8abf9edc2dad21 100644 (file)
@@ -18,6 +18,6 @@
 
 uns stk_array_len(char **s, uns cnt);
 void stk_array_copy(char *x, char **s, uns cnt);
-uns stk_printf_internal(char *x, ...) __attribute__((format(printf,1,2)));
+uns stk_printf_internal(char *x, ...) FORMAT_CHECK(printf,1,2);
 
 extern char *stk_printf_buf;