From e0cab1937a05d5c9740adf10613aa183eee7d99c Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 24 Jun 2021 14:30:40 +0200 Subject: libfstream: Add printf format specifier attribute Signed-off-by: David Oberhollenzer --- include/fstream.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/fstream.h') diff --git a/include/fstream.h b/include/fstream.h index 07ee5a7..0e8905e 100644 --- a/include/fstream.h +++ b/include/fstream.h @@ -9,6 +9,13 @@ #include "sqfs/predef.h" +#if defined(__GNUC__) || defined(__clang__) +# define PRINTF_ATTRIB(fmt, elipsis) \ + __attribute__ ((format (printf, fmt, elipsis))) +#else +# define PRINTF_ATTRIB(fmt, elipsis) +#endif + /** * @struct ostream_t * @@ -261,7 +268,8 @@ SQFS_INTERNAL const char *ostream_get_filename(ostream_t *strm); * * @return The number of characters written on success, -1 on failure. */ -SQFS_INTERNAL int ostream_printf(ostream_t *strm, const char *fmt, ...); +SQFS_INTERNAL int ostream_printf(ostream_t *strm, const char *fmt, ...) + PRINTF_ATTRIB(2, 3); /** * @brief Read a line of text from an input stream -- cgit v1.2.3