From 471f51ef9b5ae3de8511a2d1d376df18149152ee Mon Sep 17 00:00:00 2001 From: dhewg Date: Wed, 30 Nov 2011 22:27:12 +0100 Subject: [PATCH] Fix -Wformat and -Wformat-extra-args warnings Fix format specifiers and use the C99 %zd for types of size_t and alike. --- d3xp/MultiplayerGame.cpp | 2 +- d3xp/ai/AAS_routing.cpp | 6 +++--- d3xp/anim/Anim.cpp | 6 +++--- d3xp/gamesys/Event.cpp | 4 ++-- d3xp/gamesys/SysCmds.cpp | 4 ++-- d3xp/gamesys/SysCvar.cpp | 2 +- d3xp/script/Script_Program.cpp | 8 ++++---- game/MultiplayerGame.cpp | 2 +- game/ai/AAS_routing.cpp | 6 +++--- game/anim/Anim.cpp | 6 +++--- game/gamesys/Event.cpp | 2 +- game/gamesys/SysCmds.cpp | 4 ++-- game/gamesys/SysCvar.cpp | 2 +- game/script/Script_Program.cpp | 8 ++++---- idlib/Dict.cpp | 4 ++-- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/d3xp/MultiplayerGame.cpp b/d3xp/MultiplayerGame.cpp index 1e01d57..d7d2e4b 100644 --- a/d3xp/MultiplayerGame.cpp +++ b/d3xp/MultiplayerGame.cpp @@ -1364,7 +1364,7 @@ void idMultiplayerGame::PlayerStats( int clientNum, char *data, const int len ) return; } - idStr::snPrintf( data, len, "team=%d score=%ld tks=%ld", team, playerState[ clientNum ].fragCount, playerState[ clientNum ].teamFragCount ); + idStr::snPrintf( data, len, "team=%d score=%d tks=%d", team, playerState[ clientNum ].fragCount, playerState[ clientNum ].teamFragCount ); return; diff --git a/d3xp/ai/AAS_routing.cpp b/d3xp/ai/AAS_routing.cpp index bfad288..2dbf254 100644 --- a/d3xp/ai/AAS_routing.cpp +++ b/d3xp/ai/AAS_routing.cpp @@ -327,9 +327,9 @@ void idAASLocal::RoutingStats( void ) const { gameLocal.Printf( "%6d area cache (%d KB)\n", numAreaCache, totalAreaCacheMemory >> 10 ); gameLocal.Printf( "%6d portal cache (%d KB)\n", numPortalCache, totalPortalCacheMemory >> 10 ); gameLocal.Printf( "%6d total cache (%d KB)\n", numAreaCache + numPortalCache, totalCacheMemory >> 10 ); - gameLocal.Printf( "%6d area travel times (%d KB)\n", numAreaTravelTimes, ( numAreaTravelTimes * sizeof( unsigned short ) ) >> 10 ); - gameLocal.Printf( "%6d area cache entries (%d KB)\n", areaCacheIndexSize, ( areaCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); - gameLocal.Printf( "%6d portal cache entries (%d KB)\n", portalCacheIndexSize, ( portalCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); + gameLocal.Printf( "%6d area travel times (%zd KB)\n", numAreaTravelTimes, ( numAreaTravelTimes * sizeof( unsigned short ) ) >> 10 ); + gameLocal.Printf( "%6d area cache entries (%zd KB)\n", areaCacheIndexSize, ( areaCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); + gameLocal.Printf( "%6d portal cache entries (%zd KB)\n", portalCacheIndexSize, ( portalCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); } /* diff --git a/d3xp/anim/Anim.cpp b/d3xp/anim/Anim.cpp index 3904342..1dc2a94 100644 --- a/d3xp/anim/Anim.cpp +++ b/d3xp/anim/Anim.cpp @@ -1046,7 +1046,7 @@ void idAnimManager::ListAnims( void ) const { if ( animptr && *animptr ) { anim = *animptr; s = anim->Size(); - gameLocal.Printf( "%8d bytes : %2d refs : %s\n", s, anim->NumRefs(), anim->Name() ); + gameLocal.Printf( "%8zd bytes : %2d refs : %s\n", s, anim->NumRefs(), anim->Name() ); size += s; num++; } @@ -1057,8 +1057,8 @@ void idAnimManager::ListAnims( void ) const { namesize += jointnames[ i ].Size(); } - gameLocal.Printf( "\n%d memory used in %d anims\n", size, num ); - gameLocal.Printf( "%d memory used in %d joint names\n", namesize, jointnames.Num() ); + gameLocal.Printf( "\n%zd memory used in %d anims\n", size, num ); + gameLocal.Printf( "%zd memory used in %d joint names\n", namesize, jointnames.Num() ); } /* diff --git a/d3xp/gamesys/Event.cpp b/d3xp/gamesys/Event.cpp index 2214b6a..b06ff5e 100644 --- a/d3xp/gamesys/Event.cpp +++ b/d3xp/gamesys/Event.cpp @@ -866,7 +866,7 @@ void idEvent::Restore( idRestoreGame *savefile ) { // read the args savefile->ReadInt( argsize ); if ( argsize != event->eventdef->GetArgSize() ) { - savefile->Error( "idEvent::Restore: arg size (%d) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() ); + savefile->Error( "idEvent::Restore: arg size (%zd) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() ); } if ( argsize ) { event->data = eventDataAllocator.Alloc( argsize ); @@ -947,7 +947,7 @@ void idEvent::Restore( idRestoreGame *savefile ) { // read the args savefile->ReadInt( argsize ); if ( argsize != event->eventdef->GetArgSize() ) { - savefile->Error( "idEvent::Restore: arg size (%d) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() ); + savefile->Error( "idEvent::Restore: arg size (%zd) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() ); } if ( argsize ) { event->data = eventDataAllocator.Alloc( argsize ); diff --git a/d3xp/gamesys/SysCmds.cpp b/d3xp/gamesys/SysCmds.cpp index 18fba18..b31be99 100644 --- a/d3xp/gamesys/SysCmds.cpp +++ b/d3xp/gamesys/SysCmds.cpp @@ -87,7 +87,7 @@ void Cmd_EntityList_f( const idCmdArgs &args ) { size += check->spawnArgs.Allocated(); } - gameLocal.Printf( "...%d entities\n...%d bytes of spawnargs\n", count, size ); + gameLocal.Printf( "...%d entities\n...%zd bytes of spawnargs\n", count, size ); } /* @@ -1508,7 +1508,7 @@ static void Cmd_ListAnims_f( const idCmdArgs &args ) { } } - gameLocal.Printf( "%d memory used in %d entity animators\n", size, num ); + gameLocal.Printf( "%zd memory used in %d entity animators\n", size, num ); } } diff --git a/d3xp/gamesys/SysCvar.cpp b/d3xp/gamesys/SysCvar.cpp index 828015e..b3846f9 100644 --- a/d3xp/gamesys/SysCvar.cpp +++ b/d3xp/gamesys/SysCvar.cpp @@ -61,7 +61,7 @@ const char *ui_skinArgs[] = { "skins/characters/player/marine_mp", "skins/char const char *ui_teamArgs[] = { "Red", "Blue", NULL }; struct gameVersion_s { - gameVersion_s( void ) { sprintf( string, "%s.%d%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_STRING, __DATE__, __TIME__ ); } + gameVersion_s( void ) { sprintf( string, "%s.%d%s %s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_STRING, __DATE__, __TIME__ ); } char string[256]; } gameVersion; diff --git a/d3xp/script/Script_Program.cpp b/d3xp/script/Script_Program.cpp index 8603029..465c58b 100644 --- a/d3xp/script/Script_Program.cpp +++ b/d3xp/script/Script_Program.cpp @@ -1237,7 +1237,7 @@ byte *idProgram::ReserveMem(int size) { byte *res = &variables[ numVariables ]; numVariables += size; if ( numVariables > sizeof( variables ) ) { - throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) ); + throw idCompileError( va( "Exceeded global memory size (%zd bytes)", sizeof( variables ) ) ); } memset( res, 0, size ); @@ -1801,13 +1801,13 @@ void idProgram::CompileStats( void ) { gameLocal.Printf( "\nMemory usage:\n" ); gameLocal.Printf( " Strings: %d, %d bytes\n", fileList.Num(), stringspace ); - gameLocal.Printf( " Statements: %d, %d bytes\n", statements.Num(), statements.MemoryUsed() ); + gameLocal.Printf( " Statements: %d, %zd bytes\n", statements.Num(), statements.MemoryUsed() ); gameLocal.Printf( " Functions: %d, %d bytes\n", functions.Num(), funcMem ); gameLocal.Printf( " Variables: %d bytes\n", numVariables ); gameLocal.Printf( " Mem used: %d bytes\n", memused ); - gameLocal.Printf( " Static data: %d bytes\n", sizeof( idProgram ) ); + gameLocal.Printf( " Static data: %zd bytes\n", sizeof( idProgram ) ); gameLocal.Printf( " Allocated: %d bytes\n", memallocated ); - gameLocal.Printf( " Thread size: %d bytes\n\n", sizeof( idThread ) ); + gameLocal.Printf( " Thread size: %zd bytes\n\n", sizeof( idThread ) ); } /* diff --git a/game/MultiplayerGame.cpp b/game/MultiplayerGame.cpp index 8d740af..6f47e5e 100644 --- a/game/MultiplayerGame.cpp +++ b/game/MultiplayerGame.cpp @@ -935,7 +935,7 @@ void idMultiplayerGame::PlayerStats( int clientNum, char *data, const int len ) return; } - idStr::snPrintf( data, len, "team=%d score=%ld tks=%ld", team, playerState[ clientNum ].fragCount, playerState[ clientNum ].teamFragCount ); + idStr::snPrintf( data, len, "team=%d score=%d tks=%d", team, playerState[ clientNum ].fragCount, playerState[ clientNum ].teamFragCount ); return; diff --git a/game/ai/AAS_routing.cpp b/game/ai/AAS_routing.cpp index eea467f..2cb7104 100644 --- a/game/ai/AAS_routing.cpp +++ b/game/ai/AAS_routing.cpp @@ -327,9 +327,9 @@ void idAASLocal::RoutingStats( void ) const { gameLocal.Printf( "%6d area cache (%d KB)\n", numAreaCache, totalAreaCacheMemory >> 10 ); gameLocal.Printf( "%6d portal cache (%d KB)\n", numPortalCache, totalPortalCacheMemory >> 10 ); gameLocal.Printf( "%6d total cache (%d KB)\n", numAreaCache + numPortalCache, totalCacheMemory >> 10 ); - gameLocal.Printf( "%6d area travel times (%d KB)\n", numAreaTravelTimes, ( numAreaTravelTimes * sizeof( unsigned short ) ) >> 10 ); - gameLocal.Printf( "%6d area cache entries (%d KB)\n", areaCacheIndexSize, ( areaCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); - gameLocal.Printf( "%6d portal cache entries (%d KB)\n", portalCacheIndexSize, ( portalCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); + gameLocal.Printf( "%6d area travel times (%zu KB)\n", numAreaTravelTimes, ( numAreaTravelTimes * sizeof( unsigned short ) ) >> 10 ); + gameLocal.Printf( "%6d area cache entries (%zu KB)\n", areaCacheIndexSize, ( areaCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); + gameLocal.Printf( "%6d portal cache entries (%zu KB)\n", portalCacheIndexSize, ( portalCacheIndexSize * sizeof( idRoutingCache * ) ) >> 10 ); } /* diff --git a/game/anim/Anim.cpp b/game/anim/Anim.cpp index 3904342..1dc2a94 100644 --- a/game/anim/Anim.cpp +++ b/game/anim/Anim.cpp @@ -1046,7 +1046,7 @@ void idAnimManager::ListAnims( void ) const { if ( animptr && *animptr ) { anim = *animptr; s = anim->Size(); - gameLocal.Printf( "%8d bytes : %2d refs : %s\n", s, anim->NumRefs(), anim->Name() ); + gameLocal.Printf( "%8zd bytes : %2d refs : %s\n", s, anim->NumRefs(), anim->Name() ); size += s; num++; } @@ -1057,8 +1057,8 @@ void idAnimManager::ListAnims( void ) const { namesize += jointnames[ i ].Size(); } - gameLocal.Printf( "\n%d memory used in %d anims\n", size, num ); - gameLocal.Printf( "%d memory used in %d joint names\n", namesize, jointnames.Num() ); + gameLocal.Printf( "\n%zd memory used in %d anims\n", size, num ); + gameLocal.Printf( "%zd memory used in %d joint names\n", namesize, jointnames.Num() ); } /* diff --git a/game/gamesys/Event.cpp b/game/gamesys/Event.cpp index 7d6a657..cd46f36 100644 --- a/game/gamesys/Event.cpp +++ b/game/gamesys/Event.cpp @@ -715,7 +715,7 @@ void idEvent::Restore( idRestoreGame *savefile ) { // read the args savefile->ReadInt( argsize ); if ( argsize != event->eventdef->GetArgSize() ) { - savefile->Error( "idEvent::Restore: arg size (%d) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() ); + savefile->Error( "idEvent::Restore: arg size (%zd) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() ); } if ( argsize ) { event->data = eventDataAllocator.Alloc( argsize ); diff --git a/game/gamesys/SysCmds.cpp b/game/gamesys/SysCmds.cpp index b606765..bab152a 100644 --- a/game/gamesys/SysCmds.cpp +++ b/game/gamesys/SysCmds.cpp @@ -87,7 +87,7 @@ void Cmd_EntityList_f( const idCmdArgs &args ) { size += check->spawnArgs.Allocated(); } - gameLocal.Printf( "...%d entities\n...%d bytes of spawnargs\n", count, size ); + gameLocal.Printf( "...%d entities\n...%zd bytes of spawnargs\n", count, size ); } /* @@ -1439,7 +1439,7 @@ static void Cmd_ListAnims_f( const idCmdArgs &args ) { } } - gameLocal.Printf( "%d memory used in %d entity animators\n", size, num ); + gameLocal.Printf( "%zd memory used in %d entity animators\n", size, num ); } } diff --git a/game/gamesys/SysCvar.cpp b/game/gamesys/SysCvar.cpp index 93e7b49..5961814 100644 --- a/game/gamesys/SysCvar.cpp +++ b/game/gamesys/SysCvar.cpp @@ -51,7 +51,7 @@ const char *ui_skinArgs[] = { "skins/characters/player/marine_mp", "skins/char const char *ui_teamArgs[] = { "Red", "Blue", NULL }; struct gameVersion_s { - gameVersion_s( void ) { sprintf( string, "%s.%d%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_STRING, __DATE__, __TIME__ ); } + gameVersion_s( void ) { sprintf( string, "%s.%d%s %s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_STRING, __DATE__, __TIME__ ); } char string[256]; } gameVersion; diff --git a/game/script/Script_Program.cpp b/game/script/Script_Program.cpp index 8603029..465c58b 100644 --- a/game/script/Script_Program.cpp +++ b/game/script/Script_Program.cpp @@ -1237,7 +1237,7 @@ byte *idProgram::ReserveMem(int size) { byte *res = &variables[ numVariables ]; numVariables += size; if ( numVariables > sizeof( variables ) ) { - throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) ); + throw idCompileError( va( "Exceeded global memory size (%zd bytes)", sizeof( variables ) ) ); } memset( res, 0, size ); @@ -1801,13 +1801,13 @@ void idProgram::CompileStats( void ) { gameLocal.Printf( "\nMemory usage:\n" ); gameLocal.Printf( " Strings: %d, %d bytes\n", fileList.Num(), stringspace ); - gameLocal.Printf( " Statements: %d, %d bytes\n", statements.Num(), statements.MemoryUsed() ); + gameLocal.Printf( " Statements: %d, %zd bytes\n", statements.Num(), statements.MemoryUsed() ); gameLocal.Printf( " Functions: %d, %d bytes\n", functions.Num(), funcMem ); gameLocal.Printf( " Variables: %d bytes\n", numVariables ); gameLocal.Printf( " Mem used: %d bytes\n", memused ); - gameLocal.Printf( " Static data: %d bytes\n", sizeof( idProgram ) ); + gameLocal.Printf( " Static data: %zd bytes\n", sizeof( idProgram ) ); gameLocal.Printf( " Allocated: %d bytes\n", memallocated ); - gameLocal.Printf( " Thread size: %d bytes\n\n", sizeof( idThread ) ); + gameLocal.Printf( " Thread size: %zd bytes\n\n", sizeof( idThread ) ); } /* diff --git a/idlib/Dict.cpp b/idlib/Dict.cpp index 8130226..3b7b3b2 100644 --- a/idlib/Dict.cpp +++ b/idlib/Dict.cpp @@ -645,8 +645,8 @@ idDict::ShowMemoryUsage_f ================ */ void idDict::ShowMemoryUsage_f( const idCmdArgs &args ) { - idLib::common->Printf( "%5d KB in %d keys\n", globalKeys.Size() >> 10, globalKeys.Num() ); - idLib::common->Printf( "%5d KB in %d values\n", globalValues.Size() >> 10, globalValues.Num() ); + idLib::common->Printf( "%5zd KB in %d keys\n", globalKeys.Size() >> 10, globalKeys.Num() ); + idLib::common->Printf( "%5zd KB in %d values\n", globalValues.Size() >> 10, globalValues.Num() ); } /*