[PATCH] Add format attribute for buffer_printf functions

aaron+mutt at schrab.com aaron+mutt at schrab.com
Wed Apr 10 23:44:45 UTC 2019


Let compilers know that `mutt_buffer_printf()` and
`mutt_buffer_add_printf()` expect the second argument to be a
`printf`-style format string with the arguments for the format starting
at the third argument. This allows warnings to be shown if these are
incorrect.
---
 buffer.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/buffer.h b/buffer.h
index 3312ad866..22bb68b8f 100644
--- a/buffer.h
+++ b/buffer.h
@@ -42,10 +42,12 @@ void mutt_buffer_increase_size (BUFFER *, size_t);
 void mutt_buffer_fix_dptr (BUFFER *);
 
 /* These two replace the buffer contents. */
+__attribute__((format (printf,2,3)))
 int mutt_buffer_printf (BUFFER*, const char*, ...);
 void mutt_buffer_strcpy (BUFFER *, const char *);
 
 /* These append to the buffer. */
+__attribute__((format (printf,2,3)))
 int mutt_buffer_add_printf (BUFFER*, const char*, ...);
 void mutt_buffer_addstr (BUFFER*, const char*);
 void mutt_buffer_addch (BUFFER*, char);
-- 
2.20.1.613.g9968bcf4fb



More information about the Mutt-dev mailing list