Added annotations to help code analysis tools

CR: Bruce Dawson
This commit is contained in:
Sam Lantinga 2014-06-04 10:56:56 -07:00
parent fdba89977e
commit 53d9d2c232
16 changed files with 134 additions and 90 deletions

View file

@ -56,38 +56,38 @@ static void SDL_InitDynamicAPI(void);
#if DISABLE_JUMP_MAGIC
/* Can't use the macro for varargs nonsense. This is atrocious. */
#define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \
_static void SDL_Log##logname##name(int category, const char *fmt, ...) { \
_static void SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
va_list ap; initcall; va_start(ap, fmt); \
jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \
va_end(ap); \
}
#define SDL_DYNAPI_VARARGS(_static, name, initcall) \
_static int SDL_SetError##name(const char *fmt, ...) { \
_static int SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
char buf[512]; /* !!! FIXME: dynamic allocation */ \
va_list ap; initcall; va_start(ap, fmt); \
jump_table.SDL_vsnprintf(buf, sizeof (buf), fmt, ap); \
va_end(ap); \
return jump_table.SDL_SetError("%s", buf); \
} \
_static int SDL_sscanf##name(const char *buf, const char *fmt, ...) { \
_static int SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \
int retval; va_list ap; initcall; va_start(ap, fmt); \
retval = jump_table.SDL_vsscanf(buf, fmt, ap); \
va_end(ap); \
return retval; \
} \
_static int SDL_snprintf##name(char *buf, size_t buflen, const char *fmt, ...) { \
_static int SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
int retval; va_list ap; initcall; va_start(ap, fmt); \
retval = jump_table.SDL_vsnprintf(buf, buflen, fmt, ap); \
retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \
va_end(ap); \
return retval; \
} \
_static void SDL_Log##name(const char *fmt, ...) { \
_static void SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
va_list ap; initcall; va_start(ap, fmt); \
jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \
va_end(ap); \
} \
_static void SDL_LogMessage##name(int category, SDL_LogPriority priority, const char *fmt, ...) { \
_static void SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
va_list ap; initcall; va_start(ap, fmt); \
jump_table.SDL_LogMessageV(category, priority, fmt, ap); \
va_end(ap); \