shithub: choc

Download patch

ref: 14e9e565715db5e1d1fc92aa4f3d31b488b00112
parent: 51a73a6c5c724353702e01c37a1d5dc8da377bd8
author: Turo Lamminen <turotl@gmail.com>
date: Sat Feb 17 11:15:13 EST 2018

Add format string attribute to TXT_snprintf

--- a/textscreen/txt_main.h
+++ b/textscreen/txt_main.h
@@ -122,6 +122,17 @@
     TXT_INPUT_TEXT,
 } txt_input_mode_t;
 
+
+#ifdef __GNUC__
+
+#define PRINTF_ATTR(fmt, first) __attribute__((format(printf, fmt, first)))
+
+#else  // __GNUC__
+
+#define PRINTF_ATTR(fmt, first)
+
+#endif  // __GNUC__
+
 // Initialize the screen
 // Returns 1 if successful, 0 if failed.
 int TXT_Init(void);
@@ -181,7 +192,7 @@
 int TXT_vsnprintf(char *buf, size_t buf_len, const char *s, va_list args);
 
 // Safe version of snprintf().
-int TXT_snprintf(char *buf, size_t buf_len, const char *s, ...);
+int TXT_snprintf(char *buf, size_t buf_len, const char *s, ...) PRINTF_ATTR(3, 4);
 
 #endif /* #ifndef TXT_MAIN_H */