add function attributes so GCC can find bugs in calls to string formatting functions with variadic arguments

This commit is contained in:
Richard Goedeken 2019-03-03 09:41:03 -08:00
parent 8f7b6b07ca
commit b8fa2dea54
2 changed files with 9 additions and 2 deletions

View file

@ -159,8 +159,9 @@ static void FrameCallback(unsigned int FrameIndex)
}
}
static char *formatstr(const char *fmt, ...) ATTR_FMT(1, 2);
static char *formatstr(const char *fmt, ...)
char *formatstr(const char *fmt, ...)
{
int size = 128, ret;
char *str = (char *)malloc(size), *newstr;

View file

@ -22,7 +22,13 @@
#ifndef __MAIN_H__
#define __MAIN_H__
extern void DebugMessage(int level, const char *message, ...);
#if defined(__GNUC__)
#define ATTR_FMT(fmtpos, attrpos) __attribute__ ((format (printf, fmtpos, attrpos)))
#else
#define ATTR_FMT(fmtpos, attrpos)
#endif
extern void DebugMessage(int level, const char *message, ...) ATTR_FMT(2,3);
extern void DebugCallback(void *Context, int level, const char *message);
extern int g_Verbose;