Index: code/q3_ui/ui_local.h =================================================================== --- code/q3_ui/ui_local.h (revision 2085) +++ code/q3_ui/ui_local.h (working copy) @@ -623,7 +623,7 @@ // ui_syscalls.c // void trap_Print( const char *string ); -void trap_Error( const char *string ); +void trap_Error( const char *string ) __attribute__ ((noreturn)); int trap_Milliseconds( void ); void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); void trap_Cvar_Update( vmCvar_t *vmCvar ); Index: code/jpeg-8c/jerror.c =================================================================== --- code/jpeg-8c/jerror.c (revision 2085) +++ code/jpeg-8c/jerror.c (working copy) @@ -68,7 +68,7 @@ * or jpeg_destroy) at some point. */ -METHODDEF(void) +__attribute__ ((noreturn)) METHODDEF(void) error_exit (j_common_ptr cinfo) { /* Always display the message */ Index: code/renderer/tr_public.h =================================================================== --- code/renderer/tr_public.h (revision 2085) +++ code/renderer/tr_public.h (working copy) @@ -106,10 +106,10 @@ // 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 Index: code/server/sv_rankings.c =================================================================== --- code/server/sv_rankings.c (revision 2085) +++ code/server/sv_rankings.c (working copy) @@ -68,7 +68,7 @@ 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]; /* Index: code/server/server.h =================================================================== --- code/server/server.h (revision 2085) +++ code/server/server.h (working copy) @@ -307,7 +307,7 @@ // 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); Index: code/server/sv_bot.c =================================================================== --- code/server/sv_bot.c (revision 2085) +++ code/server/sv_bot.c (working copy) @@ -133,7 +133,7 @@ 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; Index: code/qcommon/q_shared.h =================================================================== --- code/qcommon/q_shared.h (revision 2085) +++ code/qcommon/q_shared.h (working copy) @@ -849,7 +849,7 @@ 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)) __attribute__ ((format (printf, 2, 3))); void QDECL Com_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2))); Index: code/qcommon/vm_x86_64.c =================================================================== --- code/qcommon/vm_x86_64.c (revision 2085) +++ code/qcommon/vm_x86_64.c (working copy) @@ -229,7 +229,7 @@ [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 @@ 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); Index: code/qcommon/qcommon.h =================================================================== --- code/qcommon/qcommon.h (revision 2085) +++ code/qcommon/qcommon.h (working copy) @@ -821,8 +821,8 @@ 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)) __attribute__ ((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 @@ 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 ); Index: code/qcommon/vm_x86_64_assembler.c =================================================================== --- code/qcommon/vm_x86_64_assembler.c (revision 2085) +++ code/qcommon/vm_x86_64_assembler.c (working copy) @@ -30,6 +30,13 @@ #include +// 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 @@ #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); Index: code/game/ai_main.h =================================================================== --- code/game/ai_main.h (revision 2085) +++ code/game/ai_main.h (working copy) @@ -290,7 +290,7 @@ #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 ); Index: code/game/g_local.h =================================================================== --- code/game/g_local.h (revision 2085) +++ code/game/g_local.h (working copy) @@ -624,10 +624,10 @@ 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__ ((noreturn)) __attribute__ ((format (printf, 1, 2))); // // g_client.c @@ -767,7 +767,7 @@ extern vmCvar_t g_proxMineTimeout; void trap_Printf( const char *fmt ); -void trap_Error( const char *fmt ); +void trap_Error( const char *fmt ) __attribute__ ((noreturn)); int trap_Milliseconds( void ); int trap_RealTime( qtime_t *qtime ); int trap_Argc( void ); Index: code/game/g_team.c =================================================================== --- code/game/g_team.c (revision 2085) +++ code/game/g_team.c (working copy) @@ -102,7 +102,7 @@ } // 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; Index: code/botlib/be_ai_chat.c =================================================================== --- code/botlib/be_ai_chat.c (revision 2085) +++ code/botlib/be_ai_chat.c (working copy) @@ -698,7 +698,7 @@ StripDoubleQuotes(token.string); if (strlen(token.string) <= 0) { - SourceError(source, "empty string", token.string); + SourceError(source, "empty string"); FreeSource(source); return NULL; } //end if Index: code/botlib/l_log.h =================================================================== --- code/botlib/l_log.h (revision 2085) +++ code/botlib/l_log.h (working copy) @@ -36,9 +36,9 @@ //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 Index: code/botlib/botlib.h =================================================================== --- code/botlib/botlib.h (revision 2085) +++ code/botlib/botlib.h (working copy) @@ -170,7 +170,7 @@ 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 Index: code/botlib/l_precomp.h =================================================================== --- code/botlib/l_precomp.h (revision 2085) +++ code/botlib/l_precomp.h (working copy) @@ -152,9 +152,9 @@ //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 Index: code/botlib/be_aas_route.c =================================================================== --- code/botlib/be_aas_route.c (revision 2085) +++ code/botlib/be_aas_route.c (working copy) @@ -1065,7 +1065,7 @@ 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) Index: code/botlib/l_struct.c =================================================================== --- code/botlib/l_struct.c (revision 2085) +++ code/botlib/l_struct.c (working copy) @@ -150,7 +150,7 @@ } //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 @@ { 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 Index: code/botlib/l_script.c =================================================================== --- code/botlib/l_script.c (revision 2085) +++ code/botlib/l_script.c (working copy) @@ -990,7 +990,7 @@ 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 @@ { 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 @@ { if(!PS_ExpectAnyToken(script, &token)) { - ScriptError(script, "Missing integer value\n", token.string); + ScriptError(script, "Missing integer value\n"); return 0; } Index: code/botlib/be_aas_main.h =================================================================== --- code/botlib/be_aas_main.h (revision 2085) +++ code/botlib/be_aas_main.h (working copy) @@ -34,7 +34,7 @@ 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 Index: code/botlib/l_script.h =================================================================== --- code/botlib/l_script.h (revision 2085) +++ code/botlib/l_script.h (working copy) @@ -240,8 +240,8 @@ //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))); Index: code/cgame/cg_local.h =================================================================== --- code/cgame/cg_local.h (revision 2085) +++ code/cgame/cg_local.h (working copy) @@ -1192,8 +1192,8 @@ 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__ ((noreturn)) __attribute__ ((format (printf, 1, 2))); void CG_StartMusic( void ); @@ -1475,7 +1475,7 @@ void trap_Print( const char *fmt ); // abort the game -void trap_Error( const char *fmt ); +void trap_Error( const char *fmt ) __attribute__ ((noreturn)); // milliseconds should only be used for performance tuning, never // for anything game related. Get time from the CG_DrawActiveFrame parameter Index: code/cgame/cg_players.c =================================================================== --- code/cgame/cg_players.c (revision 2085) +++ code/cgame/cg_players.c (working copy) @@ -2622,7 +2622,7 @@ 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 ); } } Index: code/ui/ui_shared.c =================================================================== --- code/ui/ui_shared.c (revision 2085) +++ code/ui/ui_shared.c (working copy) @@ -251,7 +251,7 @@ 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 @@ 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; Index: code/ui/ui_shared.h =================================================================== --- code/ui/ui_shared.h (revision 2085) +++ code/ui/ui_shared.h (working copy) @@ -354,8 +354,8 @@ 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__ ((noreturn)) __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); Index: code/ui/ui_local.h =================================================================== --- code/ui/ui_local.h (revision 2085) +++ code/ui/ui_local.h (working copy) @@ -915,7 +915,7 @@ // ui_syscalls.c // void trap_Print( const char *string ); -void trap_Error( const char *string ); +void trap_Error( const char *string ) __attribute__ ((noreturn)); int trap_Milliseconds( void ); void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); void trap_Cvar_Update( vmCvar_t *vmCvar ); Index: code/client/cl_main.c =================================================================== --- code/client/cl_main.c (revision 2085) +++ code/client/cl_main.c (working copy) @@ -2968,7 +2968,7 @@ 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]; Index: code/sys/sys_main.c =================================================================== --- code/sys/sys_main.c (revision 2085) +++ code/sys/sys_main.c (working copy) @@ -193,7 +193,7 @@ 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( ); @@ -362,7 +362,7 @@ Sys_Warn ================= */ -void Sys_Warn( char *warning, ... ) +static __attribute__ ((format (printf, 1, 2))) void Sys_Warn( char *warning, ... ) { va_list argptr; char string[1024]; Index: code/sys/sys_local.h =================================================================== --- code/sys/sys_local.h (revision 2085) +++ code/sys/sys_local.h (working copy) @@ -52,7 +52,7 @@ 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 ); Index: Makefile =================================================================== --- Makefile (revision 2085) +++ Makefile (working copy) @@ -943,6 +943,10 @@ 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 += -Wmissing-noreturn -Wdisabled-optimization +BASE_CFLAGS += -Werror-implicit-function-declaration ifeq ($(V),1) echo_cmd=@: