Index: src/renderer/tr_public.h =================================================================== --- src/renderer/tr_public.h (revision 2065) +++ src/renderer/tr_public.h (working copy) @@ -108,10 +108,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: src/server/server.h =================================================================== --- src/server/server.h (revision 2065) +++ src/server/server.h (working copy) @@ -288,7 +288,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: src/game/g_local.h =================================================================== --- src/game/g_local.h (revision 2065) +++ src/game/g_local.h (working copy) @@ -982,10 +982,10 @@ void FindIntermissionPoint( void ); void G_RunThink( gentity_t *ent ); void G_AdminMessage( gentity_t *ent, const char *string ); -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))); void G_Vote( gentity_t *ent, team_t team, qboolean voting ); void G_ExecuteVote( team_t team ); void G_CheckVote( team_t team ); Index: src/game/g_team.c =================================================================== --- src/game/g_team.c (revision 2065) +++ src/game/g_team.c (working copy) @@ -24,7 +24,7 @@ #include "g_local.h" // NULL for everyone -void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) +void QDECL __attribute__ ((format (printf, 2, 3))) PrintMsg( gentity_t *ent, const char *fmt, ... ) { char msg[ 1024 ]; va_list argptr; Index: src/qcommon/vm_x86_64.c =================================================================== --- src/qcommon/vm_x86_64.c (revision 2065) +++ src/qcommon/vm_x86_64.c (working copy) @@ -219,7 +219,7 @@ [OP_BLOCK_COPY] = 4, }; -void emit(const char* fmt, ...) +__attribute__ ((format (printf, 1, 2))) void emit(const char* fmt, ...) { va_list ap; char line[4096]; @@ -379,20 +379,20 @@ memcpy(currentVM->dataBase+dest, currentVM->dataBase+src, count); } -static void eop(void) +static __attribute__ ((noreturn)) void eop(void) { Com_Error(ERR_DROP, "end of program reached without return!\n"); exit(1); } -static void jmpviolation(void) +static __attribute__ ((noreturn)) void jmpviolation(void) { Com_Error(ERR_DROP, "program tried to execute code outside VM\n"); exit(1); } #ifdef DEBUG_VM -static void memviolation(void) +static __attribute__ ((noreturn)) void memviolation(void) { Com_Error(ERR_DROP, "program tried to access memory outside VM\n"); exit(1); Index: src/qcommon/parse.c =================================================================== --- src/qcommon/parse.c (revision 2065) +++ src/qcommon/parse.c (working copy) @@ -363,7 +363,7 @@ Parse_ScriptError =============== */ -static void QDECL Parse_ScriptError(script_t *script, char *str, ...) +static __attribute__ ((format (printf, 2, 3))) void QDECL Parse_ScriptError(script_t *script, const char *str, ...) { char text[1024]; va_list ap; @@ -381,7 +381,7 @@ Parse_ScriptWarning =============== */ -static void QDECL Parse_ScriptWarning(script_t *script, char *str, ...) +static __attribute__ ((format (printf, 2, 3))) void QDECL Parse_ScriptWarning(script_t *script, const char *str, ...) { char text[1024]; va_list ap; @@ -1098,7 +1098,7 @@ Parse_SourceError =============== */ -static void QDECL Parse_SourceError(source_t *source, char *str, ...) +static __attribute__ ((format (printf, 2, 3))) void QDECL Parse_SourceError(source_t *source, const char *str, ...) { char text[1024]; va_list ap; @@ -1114,7 +1114,7 @@ Parse_SourceWarning =============== */ -static void QDECL Parse_SourceWarning(source_t *source, char *str, ...) +static __attribute__ ((format (printf, 2, 3))) void QDECL Parse_SourceWarning(source_t *source, const char *str, ...) { char text[1024]; va_list ap; Index: src/qcommon/vm_x86_64_assembler.c =================================================================== --- src/qcommon/vm_x86_64_assembler.c (revision 2065) +++ src/qcommon/vm_x86_64_assembler.c (working copy) @@ -27,6 +27,13 @@ #include #include +//Ignore __attribute__ on non-gcc platforms +#ifndef __GNUC__ +#ifndef __attribute__ +#define __attribute__(x) +#endif +#endif + typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int 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: src/cgame/cg_local.h =================================================================== --- src/cgame/cg_local.h (revision 2065) +++ src/cgame/cg_local.h (working copy) @@ -1544,8 +1544,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__ ((format (printf, 1, 2))); void CG_StartMusic( void ); int CG_PlayerCount( void ); Index: src/ui/ui_shared.c =================================================================== --- src/ui/ui_shared.c (revision 2065) +++ src/ui/ui_shared.c (working copy) @@ -322,7 +322,7 @@ PC_SourceWarning ================= */ -void PC_SourceWarning( int handle, char *format, ... ) +__attribute__ ((format (printf, 2, 3))) void PC_SourceWarning( int handle, char *format, ... ) { int line; char filename[128]; @@ -345,7 +345,7 @@ PC_SourceError ================= */ -void PC_SourceError( int handle, char *format, ... ) +__attribute__ ((format (printf, 2, 3))) void PC_SourceError( int handle, char *format, ... ) { int line; char filename[128]; Index: src/ui/ui_shared.h =================================================================== --- src/ui/ui_shared.h (revision 2065) +++ src/ui/ui_shared.h (working copy) @@ -431,8 +431,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__ ((format (printf, 2, 3))); + void ( *Print )( const char *msg, ... ) __attribute__ ((format (printf, 1, 2))); void ( *Pause )( qboolean b ); int ( *ownerDrawWidth )( int ownerDraw, float scale ); const char *( *ownerDrawText )( int ownerDraw ); Index: src/client/cl_main.c =================================================================== --- src/client/cl_main.c (revision 2065) +++ src/client/cl_main.c (working copy) @@ -2997,7 +2997,7 @@ DLL glue ================ */ -void QDECL CL_RefPrintf( int print_level, const char *fmt, ...) { +__attribute__ ((format (printf, 2, 3))) void QDECL CL_RefPrintf( int print_level, const char *fmt, ...) { va_list argptr; char msg[MAXPRINTMSG]; Index: src/sys/sys_main.c =================================================================== --- src/sys/sys_main.c (revision 2065) +++ src/sys/sys_main.c (working copy) @@ -135,7 +135,7 @@ Single exit point (regular exit or in case of error) ================= */ -void Sys_Exit( int ex ) +__attribute__ ((noreturn)) void Sys_Exit( int ex ) { CON_Shutdown( ); @@ -157,7 +157,7 @@ Sys_Quit ================= */ -void Sys_Quit( void ) +__attribute__ ((noreturn)) void Sys_Quit( void ) { CL_Shutdown( ); Sys_Exit( 0 ); @@ -283,7 +283,7 @@ Sys_Error ================= */ -void Sys_Error( const char *error, ... ) +__attribute__ ((noreturn)) void Sys_Error( const char *error, ... ) { va_list argptr; char string[1024]; @@ -304,7 +304,7 @@ Sys_Warn ================= */ -void Sys_Warn( char *warning, ... ) +static __attribute__ ((format (printf, 1, 2))) void Sys_Warn( const char *warning, ... ) { va_list argptr; char string[1024]; @@ -469,7 +469,7 @@ Sys_SigHandler ================= */ -void Sys_SigHandler( int signal ) +__attribute__ ((noreturn)) void Sys_SigHandler( int signal ) { static qboolean signalcaught = qfalse; Index: src/sys/sys_local.h =================================================================== --- src/sys/sys_local.h (revision 2065) +++ src/sys/sys_local.h (working copy) @@ -52,6 +52,6 @@ void Sys_GLimpSafeInit( void ); void Sys_GLimpInit( void ); void Sys_PlatformInit( 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 2065) +++ Makefile (working copy) @@ -886,6 +886,10 @@ endif BASE_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\" +BASE_CFLAGS += -Wformat=2 -Wno-format-zero-length -Wformat-security +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=@: