From f0fc390a026dfff392ba465b76f60f3f0e5a70e2 Mon Sep 17 00:00:00 2001 From: ludwig Date: Sat, 30 Dec 2006 12:32:54 +0000 Subject: - tag more functions with gnu format attribute - fix format string bugs. still some left git-svn-id: svn://svn.icculus.org/quake3/trunk@1023 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/qcommon/cvar.c | 5 ++--- code/qcommon/net_chan.c | 3 +-- code/qcommon/q_shared.h | 12 ++++++------ code/qcommon/qcommon.h | 10 +++++----- code/qcommon/vm.c | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) (limited to 'code/qcommon') diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index e812a83..6e229c4 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -913,10 +913,9 @@ void Cvar_Update( vmCvar_t *vmCvar ) { vmCvar->modificationCount = cv->modificationCount; // bk001129 - mismatches. if ( strlen(cv->string)+1 > MAX_CVAR_VALUE_STRING ) - Com_Error( ERR_DROP, "Cvar_Update: src %s length %d exceeds MAX_CVAR_VALUE_STRING", + Com_Error( ERR_DROP, "Cvar_Update: src %s length %zd exceeds MAX_CVAR_VALUE_STRING", cv->string, - strlen(cv->string), - sizeof(vmCvar->string) ); + strlen(cv->string)); // bk001212 - Q_strncpyz guarantees zero padding and dest[MAX_CVAR_VALUE_STRING-1]==0 // bk001129 - paranoia. Never trust the destination string. // bk001129 - beware, sizeof(char*) is always 4 (for cv->string). diff --git a/code/qcommon/net_chan.c b/code/qcommon/net_chan.c index 5c92c5d..ac617cb 100644 --- a/code/qcommon/net_chan.c +++ b/code/qcommon/net_chan.c @@ -397,8 +397,7 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { if ( fragmentStart != chan->fragmentLength ) { if ( showdrop->integer || showpackets->integer ) { Com_Printf( "%s:Dropped a message fragment\n" - , NET_AdrToString( chan->remoteAddress ) - , sequence); + , NET_AdrToString( chan->remoteAddress )); } // we can still keep the part that we have so far, // so we don't need to clear chan->fragmentLength diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 335ef38..cf41290 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -599,8 +599,8 @@ int COM_GetCurrentParseLine( void ); char *COM_Parse( char **data_p ); char *COM_ParseExt( char **data_p, qboolean allowLineBreak ); int COM_Compress( char *data_p ); -void COM_ParseError( char *format, ... ); -void COM_ParseWarning( char *format, ... ); +void COM_ParseError( char *format, ... ) __attribute__ ((format (printf, 1, 2))); +void COM_ParseWarning( char *format, ... ) __attribute__ ((format (printf, 1, 2))); //int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ); #define MAX_TOKENLENGTH 1024 @@ -634,7 +634,7 @@ void Parse1DMatrix (char **buf_p, int x, float *m); void Parse2DMatrix (char **buf_p, int y, int x, float *m); void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m); -void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...); +void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); char *Com_SkipTokens( char *s, int numTokens, char *sep ); char *Com_SkipCharset( char *s, char *sep ); @@ -706,7 +706,7 @@ float LittleFloat (const float *l); void Swap_Init (void); */ -char * QDECL va(char *format, ...); +char * QDECL va(char *format, ...) __attribute__ ((format (printf, 1, 2)));; #define TRUNCATE_LENGTH 64 void Com_TruncateLongString( char *buffer, const char *s ); @@ -725,8 +725,8 @@ qboolean Info_Validate( const char *s ); void Info_NextPair( const char **s, char *key, char *value ); // this is only here so the functions in q_shared.c and bg_*.c can link -void QDECL Com_Error( int level, const char *error, ... ); -void QDECL Com_Printf( const char *msg, ... ); +void QDECL Com_Error( int level, const char *error, ... ) __attribute__ ((format (printf, 2, 3))); +void QDECL Com_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2))); /* diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 88e36b9..b07d77e 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -161,7 +161,7 @@ void NET_Restart( void ); void NET_Config( qboolean enableNetworking ); void NET_FlushPacketQueue(void); void NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to); -void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...); +void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...) __attribute__ ((format (printf, 3, 4))); void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len ); qboolean NET_CompareAdr (netadr_t a, netadr_t b); @@ -725,9 +725,9 @@ void Info_Print( const char *s ); void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *)); void Com_EndRedirect( void ); -void QDECL Com_Printf( const char *fmt, ... ); -void QDECL Com_DPrintf( const char *fmt, ... ); -void QDECL Com_Error( int code, const char *fmt, ... ); +void QDECL Com_Printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); +void QDECL Com_DPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); +void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3))); void Com_Quit_f( void ); int Com_EventLoop( void ); int Com_Milliseconds( void ); // will be journaled properly @@ -989,7 +989,7 @@ void *Sys_GetBotLibAPI( void *parms ); char *Sys_GetCurrentUser( void ); -void QDECL Sys_Error( const char *error, ...); +void QDECL Sys_Error( const char *error, ...) __attribute__ ((format (printf, 1, 2))); void Sys_Quit (void); char *Sys_GetClipboardData( void ); // note that this isn't journaled... diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c index efc0da8..0e35791 100644 --- a/code/qcommon/vm.c +++ b/code/qcommon/vm.c @@ -726,7 +726,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) { lastVM = vm; if ( vm_debugLevel ) { - Com_Printf( "VM_Call( %ld )\n", callnum ); + Com_Printf( "VM_Call( %d )\n", callnum ); } // if we have a dll loaded, call it directly -- cgit v1.2.3