From 0f43dc6df58569ceb32475c4a4009ea6de437923 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sat, 12 Jan 2013 23:55:21 +0000 Subject: Fix a bunch of warnings --- src/cgame/cg_buildable.c | 2 +- src/cgame/cg_local.h | 4 ++-- src/cgame/cg_particles.c | 4 ++-- src/cgame/cg_players.c | 2 +- src/cgame/cg_servercmds.c | 2 +- src/cgame/cg_trails.c | 2 +- src/game/bg_alloc.c | 2 +- src/game/g_admin.c | 2 +- src/game/g_buildable.c | 10 +++++----- src/game/g_cmds.c | 16 ++++++++-------- src/game/g_combat.c | 6 +++--- src/game/g_local.h | 6 +++--- src/game/g_main.c | 4 ++-- src/game/g_session.c | 4 ++-- src/game/g_team.c | 23 +---------------------- src/qcommon/parse.c | 10 ++++------ src/qcommon/q_shared.h | 2 +- src/qcommon/qcommon.h | 2 +- src/renderer/tr_public.h | 2 +- src/ui/ui_shared.c | 4 ++-- src/ui/ui_shared.h | 4 ++-- 21 files changed, 45 insertions(+), 68 deletions(-) diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index d2bbe05b..369277d1 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -438,7 +438,7 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) if( newAnimation != lf->animationNumber || !lf->animation ) { if( cg_debugRandom.integer ) - CG_Printf( "newAnimation: %d lf->animationNumber: %d lf->animation: %d\n", + CG_Printf( "newAnimation: %d lf->animationNumber: %d lf->animation: 0x%p\n", newAnimation, lf->animationNumber, lf->animation ); CG_SetBuildableLerpFrameAnimation( buildable, lf, newAnimation ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 797d0c2c..50dc8340 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1541,8 +1541,8 @@ extern vmCvar_t cg_chatTeamPrefix; 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 ); diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c index d26002a5..0e1a0357 100644 --- a/src/cgame/cg_particles.c +++ b/src/cgame/cg_particles.c @@ -793,7 +793,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) if( bp->numModels > 0 ) { CG_Printf( S_COLOR_RED "ERROR: 'shader' not allowed in " - "conjunction with 'model'\n", token ); + "conjunction with 'model'\n" ); break; } @@ -814,7 +814,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) if( bp->numFrames > 0 ) { CG_Printf( S_COLOR_RED "ERROR: 'model' not allowed in " - "conjunction with 'shader'\n", token ); + "conjunction with 'shader'\n" ); break; } diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index e5becd27..fb8e2c24 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -2355,7 +2355,7 @@ void CG_ResetPlayerEntity( centity_t *cent ) cent->pe.nonseg.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 ); } /* diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index dff02805..b501ecbc 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -1246,7 +1246,7 @@ static void CG_GameCmds_f( void ) if( len + gcmdsOffset >= sizeof( registeredCmds ) - 1 ) { CG_Printf( "AddCommand: too many commands (%d >= %d)\n", - len + gcmdsOffset, sizeof( registeredCmds ) - 1 ); + (int)( len + gcmdsOffset ), (int)( sizeof( registeredCmds ) - 1 ) ); return; } trap_AddCommand( cmd ); diff --git a/src/cgame/cg_trails.c b/src/cgame/cg_trails.c index 05f5ef5e..759ffcfe 100644 --- a/src/cgame/cg_trails.c +++ b/src/cgame/cg_trails.c @@ -898,7 +898,7 @@ static qboolean CG_ParseTrailBeam( baseTrailBeam_t *btb, char **text_p ) { if( btb->numJitters == MAX_TRAIL_BEAM_JITTERS ) { - CG_Printf( S_COLOR_RED "ERROR: too many jitters\n", token ); + CG_Printf( S_COLOR_RED "ERROR: too many jitters\n" ); break; } diff --git a/src/game/bg_alloc.c b/src/game/bg_alloc.c index b145c62e..6bf4eb63 100644 --- a/src/game/bg_alloc.c +++ b/src/game/bg_alloc.c @@ -54,7 +54,7 @@ void *BG_Alloc( int size ) char *endptr; int *ptr; - allocsize = ( size + sizeof(int) + ROUNDBITS ) & ~ROUNDBITS; // Round to 32-byte boundary + allocsize = ( size + (int)sizeof(int) + ROUNDBITS ) & ~ROUNDBITS; // Round to 32-byte boundary ptr = NULL; smallest = NULL; diff --git a/src/game/g_admin.c b/src/game/g_admin.c index c3431a89..bbc77645 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -682,7 +682,7 @@ void G_admin_authlog( gentity_t *ent ) G_LogPrintf( "AdminAuth: %i \"%s" S_COLOR_WHITE "\" \"%s" S_COLOR_WHITE "\" [%d] (%s): %s\n", - ent - g_entities, ent->client->pers.netname, + (int)( ent - g_entities ), ent->client->pers.netname, ent->client->pers.admin->name, ent->client->pers.admin->level, ent->client->pers.guid, aflags ); } diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index f1bb1c12..2fbd92e1 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -3020,7 +3020,7 @@ void G_FreeMarkedBuildables( gentity_t *deconner, char *readable, int rsize, removalCounts[ bNum ]++; if( nums ) - Q_strcat( nums, nsize, va( " %d", ent - g_entities ) ); + Q_strcat( nums, nsize, va( " %d", (int)( ent - g_entities ) ) ); G_FreeEntity( ent ); } @@ -3713,8 +3713,8 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, readable ) ); G_LogPrintf( "Construct: %d %d %s%s: %s" S_COLOR_WHITE " is building " "%s%s%s\n", - builder - g_entities, - built - g_entities, + (int)( builder - g_entities ), + (int)( built - g_entities ), BG_Buildable( built->s.modelindex )->name, buildnums, builder->client->pers.netname, @@ -4279,7 +4279,7 @@ void G_BuildLogRevertThink( gentity_t *ent ) G_KillBox( built ); G_LogPrintf( "revert: restore %d %s\n", - built - g_entities, BG_Buildable( built->s.modelindex )->name ); + (int)( built - g_entities ), BG_Buildable( built->s.modelindex )->name ); G_FreeEntity( ent ); } @@ -4313,7 +4313,7 @@ void G_BuildLogRevert( int id ) { if( ent->s.eType == ET_BUILDABLE ) G_LogPrintf( "revert: remove %d %s\n", - ent - g_entities, BG_Buildable( ent->s.modelindex )->name ); + (int)( ent - g_entities ), BG_Buildable( ent->s.modelindex )->name ); G_FreeEntity( ent ); break; } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 171df605..5398afd3 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -887,7 +887,7 @@ static qboolean G_SayTo( gentity_t *ent, gentity_t *other, saymode_t mode, const } trap_SendServerCommand( other-g_entities, va( "chat %d %d \"%s\"", - ent ? ent-g_entities : -1, + (int)( ent ? ent-g_entities : -1 ), mode, message ) ); @@ -915,7 +915,7 @@ void G_Say( gentity_t *ent, saymode_t mode, const char *chatText ) { case SAY_ALL: G_LogPrintf( "Say: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_GREEN "%s\n", - ( ent ) ? ent - g_entities : -1, + (int)( ( ent ) ? ent - g_entities : -1 ), ( ent ) ? ent->client->pers.netname : "console", chatText ); break; case SAY_TEAM: @@ -923,7 +923,7 @@ void G_Say( gentity_t *ent, saymode_t mode, const char *chatText ) if( !ent || !ent->client ) Com_Error( ERR_FATAL, "SAY_TEAM by non-client entity\n" ); G_LogPrintf( "SayTeam: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_CYAN "%s\n", - ent - g_entities, ent->client->pers.netname, chatText ); + (int)( ent - g_entities ), ent->client->pers.netname, chatText ); break; case SAY_RAW: if( ent ) @@ -968,7 +968,7 @@ static void Cmd_SayArea_f( gentity_t *ent ) range[ i ] = g_sayAreaRange.value; G_LogPrintf( "SayArea: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_BLUE "%s\n", - ent - g_entities, ent->client->pers.netname, msg ); + (int)( ent - g_entities ), ent->client->pers.netname, msg ); VectorAdd( ent->s.origin, range, maxs ); VectorSubtract( ent->s.origin, range, mins ); @@ -1122,12 +1122,12 @@ void Cmd_VSay_f( gentity_t *ent ) case VOICE_CHAN_LOCAL: trap_SendServerCommand( -1, va( "voice %d %d %d %d \"%s\"\n", - ent-g_entities, vchan, cmdNum, trackNum, text ) ); + (int)( ent-g_entities ), vchan, cmdNum, trackNum, text ) ); break; case VOICE_CHAN_TEAM: G_TeamCommand( ent->client->pers.teamSelection, va( "voice %d %d %d %d \"%s\"\n", - ent-g_entities, vchan, cmdNum, trackNum, text ) ); + (int)( ent-g_entities ), vchan, cmdNum, trackNum, text ) ); break; default: break; @@ -1469,7 +1469,7 @@ void Cmd_CallVote_f( gentity_t *ent ) G_LogPrintf( "%s: %d \"%s" S_COLOR_WHITE "\": %s\n", team == TEAM_NONE ? "CallVote" : "CallTeamVote", - ent - g_entities, ent->client->pers.netname, level.voteString[ team ] ); + (int)( ent - g_entities ), ent->client->pers.netname, level.voteString[ team ] ); if( team == TEAM_NONE ) { @@ -3338,7 +3338,7 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) G_LogPrintf( "%s: %d \"%s" S_COLOR_WHITE "\" \"%s\": ^%c%s\n", ( teamonly ) ? "TPrivMsg" : "PrivMsg", - ( ent ) ? ent - g_entities : -1, + (int)( ( ent ) ? ent - g_entities : -1 ), ( ent ) ? ent->client->pers.netname : "console", name, color, msg ); } diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 6cb06309..7fcd2310 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -271,7 +271,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int G_LogPrintf( "Die: %d %d %s: %s" S_COLOR_WHITE " killed %s\n", killer, - self - g_entities, + (int)( self - g_entities ), obit, killerName, self->client->pers.netname ); @@ -1419,8 +1419,8 @@ void G_LogDestruction( gentity_t *self, gentity_t *actor, int mod ) return; G_LogPrintf( S_COLOR_YELLOW "Deconstruct: %d %d %s %s: %s %s by %s\n", - actor - g_entities, - self - g_entities, + (int)( actor - g_entities ), + (int)( self - g_entities ), BG_Buildable( self->s.modelindex )->name, modNames[ mod ], BG_Buildable( self->s.modelindex )->humanName, diff --git a/src/game/g_local.h b/src/game/g_local.h index 05fea6df..2ba8b563 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -998,10 +998,10 @@ void CalculateRanks( void ); 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 ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 5d5fbed6..c228a5f7 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1682,7 +1682,7 @@ void G_AdminMessage( gentity_t *ent, const char *msg ) int i; Com_sprintf( string, sizeof( string ), "chat %d %d \"%s\"", - ent ? ent - g_entities : -1, + (int)( ent ? ent - g_entities : -1 ), G_admin_permission( ent, ADMF_ADMINCHAT ) ? SAY_ADMINS : SAY_ADMINS_PUBLIC, msg ); @@ -1694,7 +1694,7 @@ void G_AdminMessage( gentity_t *ent, const char *msg ) // Send to the logfile and server console G_LogPrintf( "%s: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_MAGENTA "%s\n", G_admin_permission( ent, ADMF_ADMINCHAT ) ? "AdminMsg" : "AdminMsgPublic", - ent ? ent - g_entities : -1, ent ? ent->client->pers.netname : "console", + (int)( ent ? ent - g_entities : -1 ), ent ? ent->client->pers.netname : "console", msg ); } diff --git a/src/game/g_session.c b/src/game/g_session.c index 181c7390..473cbc45 100644 --- a/src/game/g_session.c +++ b/src/game/g_session.c @@ -54,7 +54,7 @@ void G_WriteClientSessionData( gclient_t *client ) Com_ClientListString( &client->sess.ignoreList ) ); - var = va( "session%i", client - level.clients ); + var = va( "session%i", (int)( client - level.clients ) ); trap_Cvar_Set( var, s ); } @@ -74,7 +74,7 @@ void G_ReadSessionData( gclient_t *client ) int restartTeam; char ignorelist[ 17 ]; - var = va( "session%i", client - level.clients ); + var = va( "session%i", (int)( client - level.clients ) ); trap_Cvar_VariableStringBuffer( var, s, sizeof(s) ); sscanf( s, "%i %i %i %i %16s", diff --git a/src/game/g_team.c b/src/game/g_team.c index ec387acd..531e3d2e 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -23,27 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "g_local.h" -// NULL for everyone -void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) -{ - char msg[ 1024 ]; - va_list argptr; - char *p; - - va_start( argptr,fmt ); - - if( Q_vsnprintf( msg, sizeof( msg ), fmt, argptr ) > sizeof( msg ) ) - G_Error ( "PrintMsg overrun" ); - - va_end( argptr ); - - // double quotes are bad - while( ( p = strchr( msg, '"' ) ) != NULL ) - *p = '\''; - - trap_SendServerCommand( ( ( ent == NULL ) ? -1 : ent-g_entities ), va( "print \"%s\"", msg ) ); -} - /* ================ G_TeamFromString @@ -249,7 +228,7 @@ void G_ChangeTeam( gentity_t *ent, team_t newTeam ) G_UpdateTeamConfigStrings( ); G_LogPrintf( "ChangeTeam: %d %s: %s" S_COLOR_WHITE " switched teams\n", - ent - g_entities, BG_TeamName( newTeam ), ent->client->pers.netname ); + (int)( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname ); G_namelog_update_score( ent->client ); TeamplayInfoMessage( ent ); diff --git a/src/qcommon/parse.c b/src/qcommon/parse.c index b1f6efde..e1332df3 100644 --- a/src/qcommon/parse.c +++ b/src/qcommon/parse.c @@ -363,7 +363,7 @@ static void Parse_CreatePunctuationTable(script_t *script, punctuation_t *punctu Parse_ScriptError =============== */ -static void QDECL Parse_ScriptError(script_t *script, char *str, ...) +__attribute__ ((format (printf, 2, 3))) static void QDECL Parse_ScriptError(script_t *script, char *str, ...) { char text[1024]; va_list ap; @@ -381,7 +381,7 @@ static void QDECL Parse_ScriptError(script_t *script, char *str, ...) Parse_ScriptWarning =============== */ -static void QDECL Parse_ScriptWarning(script_t *script, char *str, ...) +__attribute__ ((format (printf, 2, 3))) static void QDECL Parse_ScriptWarning(script_t *script, char *str, ...) { char text[1024]; va_list ap; @@ -1098,7 +1098,7 @@ static void Parse_FreeScript(script_t *script) Parse_SourceError =============== */ -static void QDECL Parse_SourceError(source_t *source, char *str, ...) +__attribute__ ((format (printf, 2, 3))) static void QDECL Parse_SourceError(source_t *source, char *str, ...) { char text[1024]; va_list ap; @@ -1114,7 +1114,7 @@ static void QDECL Parse_SourceError(source_t *source, char *str, ...) Parse_SourceWarning =============== */ -static void QDECL Parse_SourceWarning(source_t *source, char *str, ...) +__attribute__ ((format (printf, 2, 3))) static void QDECL Parse_SourceWarning(source_t *source, char *str, ...) { char text[1024]; va_list ap; @@ -1917,7 +1917,6 @@ static int Parse_EvaluateTokens(source_t *source, token_t *tokens, signed long i int questmarkintvalue = 0; double questmarkfloatvalue = 0; int gotquestmarkvalue = qfalse; - int lastoperatortype = 0; // operator_t operator_heap[MAX_OPERATORS]; int numoperators = 0; @@ -2286,7 +2285,6 @@ static int Parse_EvaluateTokens(source_t *source, token_t *tokens, signed long i } } if (error) break; - lastoperatortype = o->operator; //if not an operator with arity 1 if (o->operator != P_LOGIC_NOT && o->operator != P_BIN_NOT) diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index 253174d1..bfb04e54 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -920,7 +920,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__ ((noreturn, format(printf, 2, 3))); +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/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 868bf43a..1a8ddd91 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -795,7 +795,7 @@ 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__ ((noreturn, format(printf, 2, 3))); +void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((format(printf, 2, 3))); void Com_Quit_f( void ) __attribute__ ((noreturn)); void Com_GameRestart(int checksumFeed, qboolean disconnect); diff --git a/src/renderer/tr_public.h b/src/renderer/tr_public.h index d95a0023..f9ededdf 100644 --- a/src/renderer/tr_public.h +++ b/src/renderer/tr_public.h @@ -111,7 +111,7 @@ typedef struct { void (QDECL *Printf)( int printLevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); // abort the game - void (QDECL *Error)( int errorLevel, const char *fmt, ...) __attribute__ ((noreturn, format (printf, 2, 3))); + 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 diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index b98127ce..fe336b95 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -326,7 +326,7 @@ void String_Init( void ) 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]; @@ -349,7 +349,7 @@ void PC_SourceWarning( int handle, char *format, ... ) 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]; diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h index 649d51f1..eedbfd36 100644 --- a/src/ui/ui_shared.h +++ b/src/ui/ui_shared.h @@ -431,8 +431,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 ); const char *( *ownerDrawText )( int ownerDraw ); -- cgit