added printf annotations for VC++'s analyzer

This commit is contained in:
myT 2022-11-22 04:58:04 +01:00
parent a7a233699e
commit 79b2457783
26 changed files with 56 additions and 48 deletions

View file

@ -53,7 +53,7 @@ libvar_t *saveroutingcache;
// Returns: -
// Changes Globals: -
//===========================================================================
void QDECL AAS_Error(char *fmt, ...)
void QDECL AAS_Error(PRINTF_FORMAT_STRING char *fmt, ...)
{
char str[1024];
va_list arglist;

View file

@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
extern aas_t aasworld;
//AAS error message
void QDECL AAS_Error(char *fmt, ...);
void QDECL AAS_Error(PRINTF_FORMAT_STRING char *fmt, ...);
//set AAS initialized
void AAS_SetInitialized(void);
//setup AAS with the given number of entities and clients

View file

@ -171,7 +171,7 @@ typedef struct bot_entitystate_s
typedef struct botlib_import_s
{
//print messages from the bot library
void (QDECL *Print)(int type, char *fmt, ...);
void (QDECL *Print)(int type, PRINTF_FORMAT_STRING char *fmt, ...);
//trace a bbox through the world
void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);
//trace a bbox against a specific entity

View file

@ -113,7 +113,7 @@ void Log_Shutdown(void)
// Returns: -
// Changes Globals: -
//===========================================================================
void QDECL Log_Write(char *fmt, ...)
void QDECL Log_Write(PRINTF_FORMAT_STRING char *fmt, ...)
{
va_list ap;
@ -130,7 +130,7 @@ void QDECL Log_Write(char *fmt, ...)
// Returns: -
// Changes Globals: -
//===========================================================================
void QDECL Log_WriteTimeStamped(char *fmt, ...)
void QDECL Log_WriteTimeStamped(PRINTF_FORMAT_STRING char *fmt, ...)
{
va_list ap;

View file

@ -36,9 +36,9 @@ void Log_Close(void);
//close log file if present
void Log_Shutdown(void);
//write to the current opened log file
void QDECL Log_Write(char *fmt, ...);
void QDECL Log_Write(PRINTF_FORMAT_STRING char *fmt, ...);
//write to the current opened log file with a time stamp
void QDECL Log_WriteTimeStamped(char *fmt, ...);
void QDECL Log_WriteTimeStamped(PRINTF_FORMAT_STRING char *fmt, ...);
//returns a pointer to the log file
FILE *Log_FilePointer(void);
//flush log file

View file

@ -114,7 +114,7 @@ token_t *freetokens; //free tokens from the heap
//list with global defines added to every source loaded
define_t *globaldefines;
void QDECL SourceError(source_t *source, char *str, ...)
void QDECL SourceError(source_t *source, PRINTF_FORMAT_STRING char *str, ...)
{
char text[1024];
va_list ap;
@ -134,7 +134,7 @@ void QDECL SourceError(source_t *source, char *str, ...)
}
void QDECL SourceWarning(source_t *source, char *str, ...)
void QDECL SourceWarning(source_t *source, PRINTF_FORMAT_STRING char *str, ...)
{
char text[1024];
va_list ap;

View file

@ -152,9 +152,9 @@ source_t *LoadSourceMemory(char *ptr, int length, char *name);
//free the given source
void FreeSource(source_t *source);
//print a source error
void QDECL SourceError(source_t *source, char *str, ...);
void QDECL SourceError(source_t *source, PRINTF_FORMAT_STRING char *str, ...);
//print a source warning
void QDECL SourceWarning(source_t *source, char *str, ...);
void QDECL SourceWarning(source_t *source, PRINTF_FORMAT_STRING char *str, ...);
#ifdef BSPC
// some of BSPC source does include game/q_shared.h and some does not

View file

@ -219,7 +219,7 @@ char *PunctuationFromNum(script_t *script, int num)
// Returns: -
// Changes Globals: -
//===========================================================================
void QDECL ScriptError(script_t *script, char *str, ...)
void QDECL ScriptError(script_t *script, PRINTF_FORMAT_STRING char *str, ...)
{
char text[1024];
va_list ap;
@ -245,7 +245,7 @@ void QDECL ScriptError(script_t *script, char *str, ...)
// Returns: -
// Changes Globals: -
//===========================================================================
void QDECL ScriptWarning(script_t *script, char *str, ...)
void QDECL ScriptWarning(script_t *script, PRINTF_FORMAT_STRING char *str, ...)
{
char text[1024];
va_list ap;

View file

@ -240,8 +240,8 @@ void FreeScript(script_t *script);
//set the base folder to load files from
void PS_SetBaseFolder(char *path);
//print a script error with filename and line number
void QDECL ScriptError(script_t *script, char *str, ...);
void QDECL ScriptError(script_t *script, PRINTF_FORMAT_STRING char *str, ...);
//print a script warning with filename and line number
void QDECL ScriptWarning(script_t *script, char *str, ...);
void QDECL ScriptWarning(script_t *script, PRINTF_FORMAT_STRING char *str, ...);

View file

@ -667,7 +667,7 @@ static void Con_FillRect( float x, float y, float w, float h, const vec4_t color
}
static void QDECL Con_HelpPrintf( const char* fmt, ... )
static void QDECL Con_HelpPrintf( PRINTF_FORMAT_STRING const char* fmt, ... )
{
va_list argptr;
va_start( argptr, fmt );

View file

@ -149,7 +149,7 @@ static void FormatQueryWS( char* query, int querySize, const char* mapName )
}
static void PrintError( mapDownload_t* dl, const char* format, ... )
static void PrintError( mapDownload_t* dl, PRINTF_FORMAT_STRING const char* format, ... )
{
va_list ap;
va_start(ap, format);

View file

@ -1732,7 +1732,7 @@ void CL_StartHunkUsers( void ) {
}
static void QDECL CL_RefPrintf( printParm_t print_level, const char* fmt, ... )
static void QDECL CL_RefPrintf( printParm_t print_level, PRINTF_FORMAT_STRING const char* fmt, ... )
{
va_list va;
char msg[MAXPRINTMSG];

View file

@ -147,7 +147,7 @@ void Com_EndRedirect (void)
// a raw string should NEVER be passed as fmt, because of "%f" type crashers
void QDECL Com_Printf( const char *fmt, ... )
void QDECL Com_Printf( PRINTF_FORMAT_STRING const char *fmt, ... )
{
char msg[MAXPRINTMSG];
@ -217,7 +217,7 @@ void QDECL Com_Printf( const char *fmt, ... )
// a Com_Printf that only shows up if the "developer" cvar is set
void QDECL Com_DPrintf( const char *fmt, ...)
void QDECL Com_DPrintf( PRINTF_FORMAT_STRING const char *fmt, ...)
{
// don't confuse non-developers with techie stuff...
if ( !com_developer || !com_developer->integer )
@ -233,7 +233,7 @@ void QDECL Com_DPrintf( const char *fmt, ...)
}
void QDECL Com_Error( int level, const char* fmt, ... )
void QDECL Com_Error( int level, PRINTF_FORMAT_STRING const char* fmt, ... )
{
static char msg[MAXPRINTMSG];
@ -245,7 +245,7 @@ void QDECL Com_Error( int level, const char* fmt, ... )
}
void QDECL Com_ErrorExt( int code, int module, qbool realError, const char *fmt, ... )
void QDECL Com_ErrorExt( int code, int module, qbool realError, PRINTF_FORMAT_STRING const char *fmt, ... )
{
static int lastErrorTime;
static int errorCount;

View file

@ -38,9 +38,9 @@ void JSONW_EndArray();
void JSONW_IntegerValue(const char* name, int number);
void JSONW_HexValue(const char* name, uint64_t number);
void JSONW_BooleanValue(const char* name, qbool value);
void JSONW_StringValue(const char* name, const char* format, ...);
void JSONW_StringValue(const char* name, PRINTF_FORMAT_STRING const char* format, ...);
void JSONW_UnnamedHex(uint64_t number);
void JSONW_UnnamedString(const char* format, ...);
void JSONW_UnnamedString(PRINTF_FORMAT_STRING const char* format, ...);
// crash.cpp
void Crash_SaveQVMPointer(vmIndex_t vmIndex, vm_t* vm);

View file

@ -1215,7 +1215,7 @@ int FS_Write( const void *buffer, int len, fileHandle_t h ) {
return len;
}
void QDECL FS_Printf( fileHandle_t h, const char *fmt, ... ) {
void QDECL FS_Printf( fileHandle_t h, PRINTF_FORMAT_STRING const char *fmt, ... ) {
va_list argptr;
char msg[MAXPRINTMSG];

View file

@ -335,7 +335,7 @@ void JSONW_BooleanValue(const char* name, qbool value)
JSONW_StringValue(name, value ? "true" : "false");
}
void JSONW_StringValue(const char* name, const char* format, ...)
void JSONW_StringValue(const char* name, PRINTF_FORMAT_STRING const char* format, ...)
{
static char buffer[4096];
@ -364,7 +364,7 @@ void JSONW_UnnamedHex(uint64_t number)
JSONW_UnnamedString(Q_itohex(number, qtrue, qtrue));
}
void JSONW_UnnamedString(const char* format, ...)
void JSONW_UnnamedString(PRINTF_FORMAT_STRING const char* format, ...)
{
static char buffer[4096];

View file

@ -564,7 +564,7 @@ void NET_SendPacket( netsrc_t sock, int length, const void* data, const netadr_t
// sends a text message in an out-of-band datagram
void QDECL NET_OutOfBandPrint( netsrc_t sock, const netadr_t& adr, const char* format, ... )
void QDECL NET_OutOfBandPrint( netsrc_t sock, const netadr_t& adr, PRINTF_FORMAT_STRING const char* format, ... )
{
char string[MAX_MSGLEN];

View file

@ -641,7 +641,7 @@ char *Q_CleanStr( char *string ) {
}
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
void QDECL Com_sprintf( char *dest, int size, PRINTF_FORMAT_STRING const char *fmt, ...) {
int len;
va_list argptr;
char bigbuffer[32000]; // big, but small enough to fit in PPC stack
@ -670,7 +670,7 @@ varargs versions of all text functions.
FIXME: make this buffer size safe someday
============
*/
const char* QDECL va( const char* format, ... )
const char* QDECL va( PRINTF_FORMAT_STRING const char* format, ... )
{
static char string[4][32000]; // in case va is called by nested functions
static int index = 0;

View file

@ -72,6 +72,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#if defined(_MSC_VER)
#include <sal.h>
#define PRINTF_FORMAT_STRING _Printf_format_string_
#else
#define PRINTF_FORMAT_STRING
#endif
#if defined(__cplusplus)
extern "C" {
#endif
@ -528,12 +536,12 @@ typedef enum {
EXT_ERRLEV_SVDISC // ERR_SERVERDISCONNECT
} extErrorLevel_t;
const char* QDECL va( const char* format, ... );
const char* QDECL va( PRINTF_FORMAT_STRING const char* format, ... );
void QDECL Com_Error( int level, const char* error, ... );
void QDECL Com_ErrorExt( int level, int module, qbool realError, const char* error, ... );
void QDECL Com_Printf( const char* msg, ... );
void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
void QDECL Com_Error( int level, PRINTF_FORMAT_STRING const char* error, ... );
void QDECL Com_ErrorExt( int level, int module, qbool realError, PRINTF_FORMAT_STRING const char* error, ... );
void QDECL Com_Printf( PRINTF_FORMAT_STRING const char* msg, ... );
void QDECL Com_sprintf( char *dest, int size, PRINTF_FORMAT_STRING const char *fmt, ... );
float Com_Clamp( float min, float max, float value );
int Com_ClampInt( int min, int max, int value );

View file

@ -126,7 +126,7 @@ void NET_Shutdown();
void NET_Restart();
void NET_FlushPacketQueue();
void NET_SendPacket( netsrc_t sock, int length, const void* data, const netadr_t& to );
void QDECL NET_OutOfBandPrint( netsrc_t sock, const netadr_t& adr, const char* format, ... );
void QDECL NET_OutOfBandPrint( netsrc_t sock, const netadr_t& adr, PRINTF_FORMAT_STRING const char* format, ... );
void QDECL NET_OutOfBandData( netsrc_t sock, const netadr_t& adr, const byte* data, int len );
qbool NET_CompareAdr( const netadr_t& a, const netadr_t& b );
@ -502,7 +502,7 @@ typedef struct cvarTableItem_s {
const char* help;
} cvarTableItem_t;
typedef void ( QDECL *printf_t )( const char* fmt, ... );
typedef void ( QDECL *printf_t )( PRINTF_FORMAT_STRING const char* fmt, ... );
cvar_t *Cvar_Get( const char *var_name, const char *value, int flags );
// creates the variable if it doesn't exist, or returns the existing one
@ -701,7 +701,7 @@ int FS_FTell( fileHandle_t f );
void FS_Flush( fileHandle_t f );
void QDECL FS_Printf( fileHandle_t f, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
void QDECL FS_Printf( fileHandle_t f, PRINTF_FORMAT_STRING const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
// like fprintf
int FS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode );
@ -843,7 +843,7 @@ void Info_Print( const char *s );
void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *));
void Com_EndRedirect( void );
void QDECL Com_DPrintf( const char *fmt, ... );
void QDECL Com_DPrintf( PRINTF_FORMAT_STRING const char *fmt, ... );
void Com_Quit( int status );
int Com_EventLoop();
int Com_Milliseconds(); // will be journaled properly
@ -1108,7 +1108,7 @@ void Sys_ShutdownInput();
void* QDECL Sys_LoadDll( const char* name, dllSyscall_t *entryPoint, dllSyscall_t systemcalls );
void Sys_UnloadDll( void* dllHandle );
void QDECL Sys_Error( const char *error, ...);
void QDECL Sys_Error( PRINTF_FORMAT_STRING const char *error, ...);
// allowed to fail and return NULL
// if it succeeds, returns memory allocated by Z_Malloc
@ -1157,7 +1157,7 @@ void Sys_MicroSleep( int us );
int64_t Sys_Microseconds();
// prints text in the debugger's output window
void Sys_DebugPrintf( const char* fmt, ... );
void Sys_DebugPrintf( PRINTF_FORMAT_STRING const char* fmt, ... );
qbool Sys_IsDebuggerAttached();
#ifndef DEDICATED

View file

@ -179,10 +179,10 @@ typedef struct {
float (*SetConsoleVisibility)( float fraction );
// print message on the local console
void (QDECL *Printf)( printParm_t printLevel, const char *fmt, ... );
void (QDECL *Printf)( printParm_t printLevel, PRINTF_FORMAT_STRING const char *fmt, ... );
// abort the game
void (QDECL *Error)( int errorLevel, const char *fmt, ... );
void (QDECL *Error)( int errorLevel, PRINTF_FORMAT_STRING const char *fmt, ... );
// milliseconds should only be used for profiling, never
// for anything game related. Get time from the refdef

View file

@ -256,7 +256,7 @@ extern cvar_t *sv_minRestartDelay;
// sv_main.c
//
void SV_FinalMessage (char *message);
void QDECL SV_SendServerCommand( client_t *cl, const char *fmt, ...);
void QDECL SV_SendServerCommand( client_t *cl, PRINTF_FORMAT_STRING const char *fmt, ...);
void SV_AddOperatorCommands();

View file

@ -133,7 +133,7 @@ void BotDrawDebugPolygons(void (*drawPoly)(int color, int numPoints, const float
BotImport_Print
==================
*/
void QDECL BotImport_Print(int type, char *fmt, ...)
void QDECL BotImport_Print(int type, PRINTF_FORMAT_STRING char *fmt, ...)
{
char str[2048];
va_list ap;

View file

@ -164,7 +164,7 @@ the client game module: "cp", "print", "chat", etc
A NULL client will broadcast to all clients
=================
*/
void QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...) {
void QDECL SV_SendServerCommand(client_t *cl, PRINTF_FORMAT_STRING const char *fmt, ...) {
va_list argptr;
byte message[MAX_MSGLEN];
client_t *client;

View file

@ -74,7 +74,7 @@ qbool Sys_LowPhysicalMemory()
// show the early console as an error dialog
void QDECL Sys_Error( const char *error, ... )
void QDECL Sys_Error( PRINTF_FORMAT_STRING const char *error, ... )
{
va_list argptr;
char text[4096];

View file

@ -127,7 +127,7 @@ int Sys_GetUptimeSeconds( qbool parent )
}
void Sys_DebugPrintf( const char* fmt, ... )
void Sys_DebugPrintf( PRINTF_FORMAT_STRING const char* fmt, ... )
{
char buffer[1024];
va_list argptr;