mirror of
https://github.com/UberGames/ioef.git
synced 2025-01-18 15:11:41 +00:00
Bug 4812 - GCC __attribute__ annotations for printf, non-returning functions etc., patch by linux@youmustbejoking.demon.co.uk and Zack Middleton
This commit is contained in:
parent
69a7ada911
commit
9dc32d55e2
30 changed files with 63 additions and 61 deletions
4
Makefile
4
Makefile
|
@ -943,6 +943,10 @@ else
|
|||
endif
|
||||
|
||||
BASE_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\"
|
||||
BASE_CFLAGS += -Wformat=2 -Wno-format-zero-length -Wformat-security -Wno-format-nonliteral
|
||||
BASE_CFLAGS += -Wstrict-aliasing=2 -Wmissing-format-attribute
|
||||
BASE_CFLAGS += -Wdisabled-optimization
|
||||
BASE_CFLAGS += -Werror-implicit-function-declaration
|
||||
|
||||
ifeq ($(V),1)
|
||||
echo_cmd=@:
|
||||
|
|
|
@ -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(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
//set AAS initialized
|
||||
void AAS_SetInitialized(void);
|
||||
//setup AAS with the given number of entities and clients
|
||||
|
|
|
@ -1065,7 +1065,7 @@ int AAS_ReadRouteCache(void)
|
|||
botimport.FS_Read(&routecacheheader, sizeof(routecacheheader_t), fp );
|
||||
if (routecacheheader.ident != RCID)
|
||||
{
|
||||
AAS_Error("%s is not a route cache dump\n");
|
||||
AAS_Error("%s is not a route cache dump\n", filename);
|
||||
return qfalse;
|
||||
} //end if
|
||||
if (routecacheheader.version != RCVERSION)
|
||||
|
|
|
@ -698,7 +698,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename)
|
|||
StripDoubleQuotes(token.string);
|
||||
if (strlen(token.string) <= 0)
|
||||
{
|
||||
SourceError(source, "empty string", token.string);
|
||||
SourceError(source, "empty string");
|
||||
FreeSource(source);
|
||||
return NULL;
|
||||
} //end if
|
||||
|
|
|
@ -170,7 +170,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, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
//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
|
||||
|
|
|
@ -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(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
//write to the current opened log file with a time stamp
|
||||
void QDECL Log_WriteTimeStamped(char *fmt, ...);
|
||||
void QDECL Log_WriteTimeStamped(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
//returns a pointer to the log file
|
||||
FILE *Log_FilePointer(void);
|
||||
//flush log 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, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
//print a source warning
|
||||
void QDECL SourceWarning(source_t *source, char *str, ...);
|
||||
void QDECL SourceWarning(source_t *source, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
#ifdef BSPC
|
||||
// some of BSPC source does include game/q_shared.h and some does not
|
||||
|
|
|
@ -990,7 +990,7 @@ int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token)
|
|||
if (token->subtype != subtype)
|
||||
{
|
||||
ScriptError(script, "expected %s, found %s",
|
||||
script->punctuations[subtype], token->string);
|
||||
script->punctuations[subtype].p, token->string);
|
||||
return 0;
|
||||
} //end if
|
||||
} //end else if
|
||||
|
@ -1158,7 +1158,7 @@ float ReadSignedFloat(script_t *script)
|
|||
{
|
||||
if(!PS_ExpectAnyToken(script, &token))
|
||||
{
|
||||
ScriptError(script, "Missing float value\n", token.string);
|
||||
ScriptError(script, "Missing float value\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ signed long int ReadSignedInt(script_t *script)
|
|||
{
|
||||
if(!PS_ExpectAnyToken(script, &token))
|
||||
{
|
||||
ScriptError(script, "Missing integer value\n", token.string);
|
||||
ScriptError(script, "Missing integer value\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
//print a script warning with filename and line number
|
||||
void QDECL ScriptWarning(script_t *script, char *str, ...);
|
||||
void QDECL ScriptWarning(script_t *script, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
|
|||
} //end if
|
||||
if (intval < intmin || intval > intmax)
|
||||
{
|
||||
SourceError(source, "value %d out of range [%d, %d]", intval, intmin, intmax);
|
||||
SourceError(source, "value %ld out of range [%ld, %ld]", intval, intmin, intmax);
|
||||
return 0;
|
||||
} //end if
|
||||
} //end if
|
||||
|
@ -160,7 +160,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
|
|||
{
|
||||
if (intval < fd->floatmin || intval > fd->floatmax)
|
||||
{
|
||||
SourceError(source, "value %d out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
|
||||
SourceError(source, "value %ld out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
|
||||
return 0;
|
||||
} //end if
|
||||
} //end if
|
||||
|
|
|
@ -1192,8 +1192,8 @@ extern vmCvar_t cg_obeliskRespawnDelay;
|
|||
const char *CG_ConfigString( int index );
|
||||
const char *CG_Argv( int arg );
|
||||
|
||||
void QDECL CG_Printf( const char *msg, ... );
|
||||
void QDECL CG_Error( const char *msg, ... );
|
||||
void QDECL CG_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
void QDECL CG_Error( const char *msg, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
void CG_StartMusic( void );
|
||||
|
||||
|
|
|
@ -2622,7 +2622,7 @@ void CG_ResetPlayerEntity( centity_t *cent ) {
|
|||
cent->pe.torso.pitching = qfalse;
|
||||
|
||||
if ( cg_debugPosition.integer ) {
|
||||
CG_Printf("%i ResetPlayerEntity yaw=%i\n", cent->currentState.number, cent->pe.torso.yawAngle );
|
||||
CG_Printf("%i ResetPlayerEntity yaw=%f\n", cent->currentState.number, cent->pe.torso.yawAngle );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2487,7 +2487,7 @@ Responses to broadcasts, etc
|
|||
void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
|
||||
char *s;
|
||||
char *c;
|
||||
int challenge;
|
||||
int challenge = 0;
|
||||
|
||||
MSG_BeginReadingOOB( msg );
|
||||
MSG_ReadLong( msg ); // skip the -1
|
||||
|
@ -2968,7 +2968,7 @@ CL_RefPrintf
|
|||
DLL glue
|
||||
================
|
||||
*/
|
||||
void QDECL CL_RefPrintf( int print_level, const char *fmt, ...) {
|
||||
static __attribute__ ((format (printf, 2, 3))) void QDECL CL_RefPrintf( int print_level, const char *fmt, ...) {
|
||||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ extern float floattime;
|
|||
#define FloatTime() floattime
|
||||
|
||||
// from the game source
|
||||
void QDECL BotAI_Print(int type, char *fmt, ...);
|
||||
void QDECL BotAI_Print(int type, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
void QDECL QDECL BotAI_BotInitialChat( bot_state_t *bs, char *type, ... );
|
||||
void BotAI_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);
|
||||
int BotAI_GetClientState( int clientNum, playerState_t *state );
|
||||
|
|
|
@ -624,10 +624,10 @@ void SetLeader(int team, int client);
|
|||
void CheckTeamLeader( int team );
|
||||
void G_RunThink (gentity_t *ent);
|
||||
void AddTournamentQueue(gclient_t *client);
|
||||
void QDECL G_LogPrintf( const char *fmt, ... );
|
||||
void QDECL G_LogPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
void SendScoreboardMessageToAllClients( void );
|
||||
void QDECL G_Printf( const char *fmt, ... );
|
||||
void QDECL G_Error( const char *fmt, ... );
|
||||
void QDECL G_Printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
void QDECL G_Error( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
//
|
||||
// g_client.c
|
||||
|
|
|
@ -102,7 +102,7 @@ const char *TeamColorString(int team) {
|
|||
}
|
||||
|
||||
// NULL for everyone
|
||||
void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {
|
||||
static __attribute__ ((format (printf, 2, 3))) void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {
|
||||
char msg[1024];
|
||||
va_list argptr;
|
||||
char *p;
|
||||
|
|
|
@ -68,7 +68,7 @@ const char * const jpeg_std_message_table[] = {
|
|||
* or jpeg_destroy) at some point.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
__attribute__ ((noreturn)) METHODDEF(void)
|
||||
error_exit (j_common_ptr cinfo)
|
||||
{
|
||||
/* Always display the message */
|
||||
|
|
|
@ -260,19 +260,10 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
|
|||
va_list argptr;
|
||||
static int lastErrorTime;
|
||||
static int errorCount;
|
||||
static qboolean calledSysError = qfalse;
|
||||
int currentTime;
|
||||
|
||||
if(com_errorEntered)
|
||||
{
|
||||
if(!calledSysError)
|
||||
{
|
||||
calledSysError = qtrue;
|
||||
Sys_Error("recursive error after: %s", com_errorMessage);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
Sys_Error("recursive error after: %s", com_errorMessage);
|
||||
|
||||
com_errorEntered = qtrue;
|
||||
|
||||
|
@ -348,7 +339,6 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
|
|||
|
||||
Com_Shutdown ();
|
||||
|
||||
calledSysError = qtrue;
|
||||
Sys_Error ("%s", com_errorMessage);
|
||||
}
|
||||
|
||||
|
|
|
@ -849,7 +849,7 @@ 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, ... ) __attribute__ ((format (printf, 2, 3)));
|
||||
void QDECL Com_Error( int level, const char *error, ... ) __attribute__ ((noreturn, format(printf, 2, 3)));
|
||||
void QDECL Com_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
|
||||
|
|
|
@ -821,8 +821,8 @@ void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *));
|
|||
void Com_EndRedirect( void );
|
||||
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 );
|
||||
void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((noreturn, format(printf, 2, 3)));
|
||||
void Com_Quit_f( void ) __attribute__ ((noreturn));
|
||||
void Com_GameRestart(int checksumFeed, qboolean disconnect);
|
||||
|
||||
int Com_Milliseconds( void ); // will be journaled properly
|
||||
|
@ -1087,8 +1087,8 @@ void *Sys_GetBotLibAPI( void *parms );
|
|||
|
||||
char *Sys_GetCurrentUser( void );
|
||||
|
||||
void QDECL Sys_Error( const char *error, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
void Sys_Quit (void);
|
||||
void QDECL Sys_Error( const char *error, ...) __attribute__ ((noreturn)) __attribute__ ((format (printf, 1, 2)));
|
||||
void Sys_Quit (void) __attribute__ ((noreturn));
|
||||
char *Sys_GetClipboardData( void ); // note that this isn't journaled...
|
||||
|
||||
void Sys_Print( const char *msg );
|
||||
|
|
|
@ -229,7 +229,7 @@ static unsigned char op_argsize[256] =
|
|||
[OP_BLOCK_COPY] = 4,
|
||||
};
|
||||
|
||||
void emit(const char* fmt, ...)
|
||||
static __attribute__ ((format (printf, 1, 2))) void emit(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char line[4096];
|
||||
|
@ -381,26 +381,26 @@ static void* getentrypoint(vm_t* vm)
|
|||
return vm->codeBase;
|
||||
}
|
||||
|
||||
static void CROSSCALL eop(void)
|
||||
static __attribute__ ((noreturn)) void CROSSCALL eop(void)
|
||||
{
|
||||
Com_Error(ERR_DROP, "End of program reached without return!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void CROSSCALL jmpviolation(void)
|
||||
static __attribute__ ((noreturn)) void CROSSCALL jmpviolation(void)
|
||||
{
|
||||
Com_Error(ERR_DROP, "Program tried to execute code outside VM");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VM
|
||||
static void CROSSCALL memviolation(void)
|
||||
static __attribute__ ((noreturn)) void CROSSCALL memviolation(void)
|
||||
{
|
||||
Com_Error(ERR_DROP, "Program tried to access memory outside VM, or unaligned memory access");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void CROSSCALL opstackviolation(void)
|
||||
static __attribute__ ((noreturn)) void CROSSCALL opstackviolation(void)
|
||||
{
|
||||
Com_Error(ERR_DROP, "Program corrupted the VM opStack");
|
||||
exit(1);
|
||||
|
|
|
@ -30,6 +30,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
// Ignore __attribute__ on non-gcc platforms
|
||||
#ifndef __GNUC__
|
||||
#ifndef __attribute__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
|
@ -55,7 +62,7 @@ static FILE* fout;
|
|||
#define debug(fmt, args...)
|
||||
#endif
|
||||
|
||||
static void _crap(const char* func, const char* fmt, ...)
|
||||
static __attribute__ ((noreturn)) __attribute__ ((format (printf, 2, 3))) void _crap(const char* func, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
fprintf(stderr, "%s() - ", func);
|
||||
|
|
|
@ -106,10 +106,10 @@ typedef struct {
|
|||
//
|
||||
typedef struct {
|
||||
// print message on the local console
|
||||
void (QDECL *Printf)( int printLevel, const char *fmt, ...);
|
||||
void (QDECL *Printf)( int printLevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
// abort the game
|
||||
void (QDECL *Error)( int errorLevel, const char *fmt, ...);
|
||||
void (QDECL *Error)( int errorLevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
// milliseconds should only be used for profiling, never
|
||||
// for anything game related. Get time from the refdef
|
||||
|
|
|
@ -310,7 +310,7 @@ extern cvar_t *sv_voip;
|
|||
// 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, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
|
||||
void SV_AddOperatorCommands (void);
|
||||
|
|
|
@ -133,7 +133,7 @@ void BotDrawDebugPolygons(void (*drawPoly)(int color, int numPoints, float *poin
|
|||
BotImport_Print
|
||||
==================
|
||||
*/
|
||||
static void QDECL BotImport_Print(int type, char *fmt, ...)
|
||||
static __attribute__ ((format (printf, 2, 3))) void QDECL BotImport_Print(int type, char *fmt, ...)
|
||||
{
|
||||
char str[2048];
|
||||
va_list ap;
|
||||
|
|
|
@ -68,7 +68,7 @@ static void SV_RankEncodeGameID( uint64_t game_id, char* result,
|
|||
static uint64_t SV_RankDecodePlayerID( const char* string );
|
||||
static void SV_RankDecodePlayerKey( const char* string, GR_PLAYER_TOKEN key );
|
||||
static char* SV_RankStatusString( GR_STATUS status );
|
||||
static void SV_RankError( const char* fmt, ... );
|
||||
static void SV_RankError( const char* fmt, ... ) __attribute__ ((format (printf, 1, 2)));
|
||||
static char SV_RankGameKey[64];
|
||||
|
||||
/*
|
||||
|
|
|
@ -52,7 +52,7 @@ void Sys_GLimpSafeInit( void );
|
|||
void Sys_GLimpInit( void );
|
||||
void Sys_PlatformInit( void );
|
||||
void Sys_PlatformExit( void );
|
||||
void Sys_SigHandler( int signal );
|
||||
void Sys_SigHandler( int signal ) __attribute__ ((noreturn));
|
||||
void Sys_ErrorDialog( const char *error );
|
||||
void Sys_AnsiColorPrint( const char *msg );
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ Sys_Exit
|
|||
Single exit point (regular exit or in case of error)
|
||||
=================
|
||||
*/
|
||||
static void Sys_Exit( int exitCode )
|
||||
static __attribute__ ((noreturn)) void Sys_Exit( int exitCode )
|
||||
{
|
||||
CON_Shutdown( );
|
||||
|
||||
|
@ -351,18 +351,18 @@ void Sys_Error( const char *error, ... )
|
|||
Q_vsnprintf (string, sizeof(string), error, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
CL_Shutdown(string, qtrue);
|
||||
Sys_ErrorDialog( string );
|
||||
|
||||
Sys_Exit( 3 );
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
=================
|
||||
Sys_Warn
|
||||
=================
|
||||
*/
|
||||
void Sys_Warn( char *warning, ... )
|
||||
static __attribute__ ((format (printf, 1, 2))) void Sys_Warn( char *warning, ... )
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
@ -373,6 +373,7 @@ void Sys_Warn( char *warning, ... )
|
|||
|
||||
CON_Print( va( "Warning: %s", string ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
============
|
||||
|
|
|
@ -251,7 +251,7 @@ void String_Init(void) {
|
|||
PC_SourceWarning
|
||||
=================
|
||||
*/
|
||||
void PC_SourceWarning(int handle, char *format, ...) {
|
||||
static __attribute__ ((format (printf, 2, 3))) void PC_SourceWarning(int handle, char *format, ...) {
|
||||
int line;
|
||||
char filename[128];
|
||||
va_list argptr;
|
||||
|
@ -273,7 +273,7 @@ void PC_SourceWarning(int handle, char *format, ...) {
|
|||
PC_SourceError
|
||||
=================
|
||||
*/
|
||||
void PC_SourceError(int handle, char *format, ...) {
|
||||
static __attribute__ ((format (printf, 2, 3))) void PC_SourceError(int handle, char *format, ...) {
|
||||
int line;
|
||||
char filename[128];
|
||||
va_list argptr;
|
||||
|
|
|
@ -354,8 +354,8 @@ typedef struct {
|
|||
void (*getBindingBuf)( int keynum, char *buf, int buflen );
|
||||
void (*setBinding)( int keynum, const char *binding );
|
||||
void (*executeText)(int exec_when, const char *text );
|
||||
void (*Error)(int level, const char *error, ...);
|
||||
void (*Print)(const char *msg, ...);
|
||||
void (*Error)(int level, const char *error, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
void (*Print)(const char *msg, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
void (*Pause)(qboolean b);
|
||||
int (*ownerDrawWidth)(int ownerDraw, float scale);
|
||||
sfxHandle_t (*registerSound)(const char *name, qboolean compressed);
|
||||
|
|
Loading…
Reference in a new issue