log/llog: add gcc format checks

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>
This commit is contained in:
David Herrmann 2012-09-30 15:41:08 +02:00
parent 26fae42b0c
commit e0d30b2283
2 changed files with 17 additions and 12 deletions

View File

@ -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, ...)
{
}

View 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, ...)
{
}