]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Set printf format attribute for logging functions with gcc
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 26 Nov 2013 15:11:55 +0000 (16:11 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 26 Nov 2013 17:41:49 +0000 (18:41 +0100)
logging.h

index 6f8e3f51772e814aa60fb9744f1368b046d5837c..858ce85308ec808851dbcdd234c4376015d3d148 100644 (file)
--- a/logging.h
+++ b/logging.h
 
 #ifdef __GNUC__
 #define FUNCTION_NAME __FUNCTION__
+#define FORMAT_ATTRIBUTE_PRINTF(str, first) __attribute__ ((format (printf, str, first)))
 #else
 #define FUNCTION_NAME ""
+#define FORMAT_ATTRIBUTE_PRINTF(str, first)
 #endif
 
 #define LOG(severity, facility, ...) LOG_Message(severity, facility, __LINE__, __FILE__, FUNCTION_NAME, __VA_ARGS__)
@@ -88,6 +90,7 @@ extern void LOG_Initialise(void);
 extern void LOG_Finalise(void);
 
 /* Line logging function */
+FORMAT_ATTRIBUTE_PRINTF(6, 7)
 extern void LOG_Message(LOG_Severity severity, LOG_Facility facility,
                         int line_number, const char *filename,
                         const char *function_name, const char *format, ...);
@@ -109,6 +112,8 @@ extern int LOG_RateLimited(void);
 typedef int LOG_FileID;
 
 extern LOG_FileID LOG_FileOpen(const char *name, const char *banner);
+
+FORMAT_ATTRIBUTE_PRINTF(2, 3)
 extern void LOG_FileWrite(LOG_FileID id, const char *format, ...);
 
 extern void LOG_CreateLogFileDir(void);