changeset 2383:43e39d9ec42f

Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jan 2020 14:55:41 +0200
parents 947eba01f3f3
children 36edd316184a
files src/dmlib.h src/dmres.h src/dmtext.h tools/lib64util.c tools/libgutil.h
diffstat 5 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmlib.h	Wed Jan 08 14:59:16 2020 +0200
+++ b/src/dmlib.h	Thu Jan 09 14:55:41 2020 +0200
@@ -373,13 +373,17 @@
 void       dmPrintBanner(FILE *outFile, const char *name, const char *usage);
 
 void       dmMsgVA(int level, const char *fmt, va_list ap);
-void       dmMsg(int level, const char *fmt, ...);
+void       dmMsg(int level, const char *fmt, ...)
+           __attribute__ ((__format__ (__printf__, 2, 3)));
 void       dmPrintVA(int level, const char *fmt, va_list ap);
-void       dmPrint(int level, const char *fmt, ...);
+void       dmPrint(int level, const char *fmt, ...)
+           __attribute__ ((__format__ (__printf__, 2, 3)));
 
 int        dmErrorVA(const int error, const char *fmt, va_list);
-int        dmError(const int error, const char *fmt, ...);
-void       dmErrorMsg(const char *fmt, ...);
+int        dmError(const int error, const char *fmt, ...)
+           __attribute__ ((__format__ (__printf__, 2, 3)));
+void       dmErrorMsg(const char *fmt, ...)
+           __attribute__ ((__format__ (__printf__, 1, 2)));
 int        dmGetErrno();
 const char *dmErrorStr(const int error);
 
--- a/src/dmres.h	Wed Jan 08 14:59:16 2020 +0200
+++ b/src/dmres.h	Thu Jan 09 14:55:41 2020 +0200
@@ -172,7 +172,8 @@
 char *       dmfgets(char *str, const int size, DMResource *fh);
 int          dmfputs(const char *str, DMResource *fh);
 int          dmvfprintf(DMResource *fh, const char *fmt, va_list ap);
-int          dmfprintf(DMResource *fh, const char *fmt, ...);
+int          dmfprintf(DMResource *fh, const char *fmt, ...)
+             __attribute__ ((__format__ (__printf__, 2, 3)));
 
 // Helper functions for endianess based reading etc
 BOOL         dmf_read_str(DMResource *fh, void *ptr, const size_t len);
--- a/src/dmtext.h	Wed Jan 08 14:59:16 2020 +0200
+++ b/src/dmtext.h	Thu Jan 09 14:55:41 2020 +0200
@@ -68,7 +68,8 @@
 void dmDrawBMTextVA(SDL_Surface *screen, const DMBitmapFont *font,
     const BOOL condensed, const int mode, const int xc, const int yc, const char *fmt, va_list ap);
 void dmDrawBMText(SDL_Surface *screen, const DMBitmapFont *font,
-    const BOOL condensed, const int mode, const int xc, const int yc, const char *fmt, ...);
+    const BOOL condensed, const int mode, const int xc, const int yc, const char *fmt, ...)
+    __attribute__ ((__format__ (__printf__, 7, 8)));
 
 
 static inline void dmInitializeGetBMGlyphSurface(SDL_Surface *surf, DMBitmapFont *font)
--- a/tools/lib64util.c	Wed Jan 08 14:59:16 2020 +0200
+++ b/tools/lib64util.c	Thu Jan 09 14:55:41 2020 +0200
@@ -110,6 +110,7 @@
 }
 
 
+__attribute__ ((__format__ (__printf__, 4, 5)))
 static void dmC64ImageDumpLine(FILE *fh, const char *indent, const char *field, const char *fmt, ...)
 {
     va_list ap;
--- a/tools/libgutil.h	Wed Jan 08 14:59:16 2020 +0200
+++ b/tools/libgutil.h	Thu Jan 09 14:55:41 2020 +0200
@@ -22,7 +22,8 @@
 void dmFillBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 bgcol, Uint32 ucol, Uint32 dcol);
 void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt);
 void dmDrawBMTextVAQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap);
-void dmDrawBMTextQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...);
+void dmDrawBMTextQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...)
+     __attribute__ ((__format__ (__printf__, 6, 7)));
 
 
 #ifdef __cplusplus