[kvm-unit-tests PATCH 1/4] lib: *printf: warn on format/arg mismatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Suggested-by: Thomas Huth <thuth@xxxxxxxxxx>
Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/libcflat.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 39100f29713b8..ce09d34e658b3 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -51,13 +51,15 @@ typedef _Bool		bool;
 extern void puts(const char *s);
 extern void exit(int code);
 extern void abort(void);
-
-extern int printf(const char *fmt, ...);
-extern int snprintf(char *buf, int size, const char *fmt, ...);
-extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
-extern int vprintf(const char *fmt, va_list va);
 extern long atol(const char *ptr);
 
+#define _f(i,j) __attribute__((format(printf, i, j)))
+extern int printf(const char *fmt, ...) _f(1,2);
+extern int snprintf(char *buf, int size, const char *fmt, ...) _f(3,4);
+extern int vsnprintf(char *buf, int size, const char *fmt, va_list va) _f(3,0);
+extern int vprintf(const char *fmt, va_list va) _f(1,0);
+#undef _f
+
 extern void report_prefix_push(const char *prefix);
 extern void report_prefix_pop(void);
 extern void report(const char *msg_fmt, bool pass, ...);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux