[Pdbg] [PATCH] debug: Add printf attribute to logging function

Joel Stanley joel at jms.id.au
Fri May 25 13:15:31 AEST 2018


This allows the compiler to warn about mismatched types in printf
arguments.

Without this we don't get warnings from the logging macros when format
specifiers and arguments don't match up, and instead you get segfaults.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 libpdbg/debug.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libpdbg/debug.h b/libpdbg/debug.h
index c318e3a566e6..5fc027a64ead 100644
--- a/libpdbg/debug.h
+++ b/libpdbg/debug.h
@@ -18,6 +18,8 @@
 
 #include "libpdbg.h"
 
+void pdbg_log(int log_level, const char* fmt, ...) __attribute__((format (printf, 2, 3)));
+
 #define PR_ERROR(x, args...) \
 	pdbg_log(PDBG_ERROR, x, ##args)
 #define PR_WARNING(x, args...) \
-- 
2.17.0



More information about the Pdbg mailing list