log/llog: add gcc format checks
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 30 Sep 2012 13:41:08 +0000 (15:41 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 30 Sep 2012 13:41:08 +0000 (15:41 +0200)
Add gcc attributes so the printf formats are correctly checked. This
causes a lot of warnings which will be fixed in the following commits.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/log.h
src/shl_llog.h

index 52b07f6..d972942 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -176,6 +176,7 @@ void log_clean_filter();
  * some log-message at application start. This is a handy-helper to do this.
  */
 
+__attribute__((format(printf, 7, 0)))
 void log_submit(const char *file,
                int line,
                const char *func,
@@ -185,6 +186,7 @@ void log_submit(const char *file,
                const char *format,
                va_list args);
 
+__attribute__((format(printf, 7, 8)))
 void log_format(const char *file,
                int line,
                const char *func,
@@ -194,6 +196,7 @@ void log_format(const char *file,
                const char *format,
                ...);
 
+__attribute__((format(printf, 6, 0)))
 void log_llog(const char *file,
              int line,
              const char *func,
@@ -205,7 +208,8 @@ void log_llog(const char *file,
 int log_set_file(const char *file);
 void log_print_init(const char *appname);
 
-static inline void log_dummyf(unsigned int sev, const char *format, ...)
+static inline __attribute__((format(printf, 2, 3)))
+void log_dummyf(unsigned int sev, const char *format, ...)
 {
 }
 
index 0325957..29443af 100644 (file)
@@ -71,15 +71,15 @@ typedef void (*llog_submit_t) (const char *file,
                               const char *format,
                               va_list args);
 
-__attribute__((__unused__))
-static void llog_format(llog_submit_t llog,
-                       const char *file,
-                       int line,
-                       const char *func,
-                       const char *subs,
-                       unsigned int sev,
-                       const char *format,
-                       ...)
+static inline __attribute__((format(printf, 7, 8)))
+void llog_format(llog_submit_t llog,
+                const char *file,
+                int line,
+                const char *func,
+                const char *subs,
+                unsigned int sev,
+                const char *format,
+                ...)
 {
        va_list list;
 
@@ -101,8 +101,9 @@ static const char *LLOG_SUBSYSTEM __attribute__((__unused__));
 #define llog_dprintf(obj, sev, format, ...) \
        llog_format((obj), LLOG_DEFAULT, (sev), (format), ##__VA_ARGS__)
 
-static inline void llog_dummyf(llog_submit_t llog, unsigned int sev,
-                              const char *format, ...)
+static inline __attribute__((format(printf, 3, 4)))
+void llog_dummyf(llog_submit_t llog, unsigned int sev,
+                const char *format, ...)
 {
 }