From 40d251637126d8104943ddb6e8c6b1790caf7159 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 3 Apr 2009 12:01:47 +0200 Subject: [PATCH] [BUILD] add format(printf) to printf-like functions Doing this helps catching warnings about wrong output formats. --- include/proto/buffers.h | 3 ++- include/proto/log.h | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/proto/buffers.h b/include/proto/buffers.h index a8f536a751..dc9961a2bd 100644 --- a/include/proto/buffers.h +++ b/include/proto/buffers.h @@ -277,7 +277,8 @@ int buffer_write_chunk(struct buffer *buf, struct chunk *chunk); int buffer_replace(struct buffer *b, char *pos, char *end, const char *str); int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int len); int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len); -int chunk_printf(struct chunk *chk, int size, const char *fmt, ...); +int chunk_printf(struct chunk *chk, int size, const char *fmt, ...) + __attribute__ ((format(printf, 3, 4))); void buffer_dump(FILE *o, struct buffer *b, int from, int to); /* diff --git a/include/proto/log.h b/include/proto/log.h index 4f6eed7f0a..f2ecf0b909 100644 --- a/include/proto/log.h +++ b/include/proto/log.h @@ -38,17 +38,20 @@ extern struct pool_head *pool2_requri; * Displays the message on stderr with the date and pid. Overrides the quiet * mode during startup. */ -void Alert(const char *fmt, ...); +void Alert(const char *fmt, ...) + __attribute__ ((format(printf, 1, 2))); /* * Displays the message on stderr with the date and pid. */ -void Warning(const char *fmt, ...); +void Warning(const char *fmt, ...) + __attribute__ ((format(printf, 1, 2))); /* * Displays the message on only if quiet mode is not set. */ -void qfprintf(FILE *out, const char *fmt, ...); +void qfprintf(FILE *out, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); /* * This function sends a syslog message to both log servers of a proxy, @@ -56,7 +59,8 @@ void qfprintf(FILE *out, const char *fmt, ...); * It also tries not to waste too much time computing the message header. * It doesn't care about errors nor does it report them. */ -void send_log(struct proxy *p, int level, const char *message, ...); +void send_log(struct proxy *p, int level, const char *message, ...) + __attribute__ ((format(printf, 3, 4))); /* * send a log for the session when we have enough info about it -- 2.47.2