Merge pull request #80 from abergmeier/fix_formats

Force format invocations to be correct (on gcc and clang) and fix them.
This commit is contained in:
Robert Beckebans 2014-02-23 19:45:54 +01:00
commit 4855d74e84
11 changed files with 18 additions and 16 deletions

View file

@ -38,6 +38,8 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_definitions(-pipe)
#add_definitions(-Wall)
add_definitions(-Werror=format-security)
add_definitions(-Werror=format)
add_definitions(-mmmx -msse -msse2)
if(WIN32)
# require msvcr70.dll or newer for _aligned_malloc etc

View file

@ -1074,7 +1074,7 @@ void idCommonLocal::Init( int argc, const char* const* argv, const char* cmdline
// clear warning buffer
ClearWarnings( GAME_NAME " initialization" );
idLib::Printf( va( "Command line: %s\n", cmdline ) );
idLib::Printf( "Command line: %s\n", cmdline );
//::MessageBox( NULL, cmdline, "blah", MB_OK );
// parse command line options
idCmdArgs args;

View file

@ -1085,7 +1085,7 @@ bool HandleCommonErrors( const idSaveLoadParms& parms )
}
else if( parms.GetError() & SAVEGAME_E_INVALID_FILENAME )
{
idLib::Warning( va( "Invalid savegame filename [%s]!", parms.directory.c_str() ) );
idLib::Warning( "Invalid savegame filename [%s]!", parms.directory.c_str() );
return true;
}
else if( parms.GetError() & SAVEGAME_E_DLC_NOT_FOUND )

View file

@ -113,7 +113,7 @@ int FS_WriteFloatString( char* buf, const char* fmt, va_list argPtr )
index += sprintf( buf + index, format.c_str(), str );
break;
case '%':
index += sprintf( buf + index, format.c_str() ); //-V618
index += sprintf( buf + index, "%s", format.c_str() );
break;
default:
common->Error( "FS_WriteFloatString: invalid format %s", format.c_str() );
@ -844,7 +844,7 @@ int idFile_Memory::Write( const void* buffer, int len )
{
if( maxSize != 0 )
{
common->Error( "idFile_Memory::Write: exceeded maximum size %d", maxSize );
common->Error( "idFile_Memory::Write: exceeded maximum size %lu", maxSize );
return 0;
}
int extra = granularity * ( 1 + alloc / granularity );
@ -930,7 +930,7 @@ void idFile_Memory::PreAllocate( size_t len )
{
if( maxSize != 0 )
{
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %d", maxSize );
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %lu", maxSize );
}
char* newPtr = ( char* )Mem_Alloc( len, TAG_IDFILE );
if( allocated > 0 )
@ -1116,7 +1116,7 @@ void idFile_Memory::TruncateData( size_t len )
{
if( len > allocated )
{
idLib::Error( "idFile_Memory::TruncateData: len (%d) exceeded allocated size (%d)", len, allocated );
idLib::Error( "idFile_Memory::TruncateData: len (%lu) exceeded allocated size (%lu)", len, allocated );
}
else
{

View file

@ -504,7 +504,7 @@ bool idZipBuilder::CreateZipFileFromFiles( const idList< idFile_Memory* >& srcFi
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
if( errcode != ZIP_OK )
{
idLib::Warning( "Error writing to zipfile (%i bytes)!", bytesRead );
idLib::Warning( "Error writing to zipfile (%lu bytes)!", bytesRead );
continue;
}
}
@ -612,7 +612,7 @@ bool idZipBuilder::AddFile( zipFile zf, idFile_Memory* src, bool deleteFile )
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
if( errcode != ZIP_OK )
{
idLib::Warning( "Error writing to zipfile (%i bytes)!", bytesRead );
idLib::Warning( "Error writing to zipfile (%lu bytes)!", bytesRead );
continue;
}
}

View file

@ -843,7 +843,7 @@ void idCommonLocal::Frame()
// the FPU stack better be empty at this point or some bad code or compiler bug left values on the stack
if( !Sys_FPU_StackIsEmpty() )
{
Printf( Sys_FPU_GetState() );
Printf( "%s", Sys_FPU_GetState() );
FatalError( "idCommon::Frame: the FPU stack is not empty at the end of the frame\n" );
}

View file

@ -289,7 +289,7 @@ void idBoundsTrack::Test()
FindBoundsIntersectionsSimSIMD( shortTestBounds, boundsList, maxIndex, intersectedIndexes2 );
}
const int64 stop = Sys_Microseconds();
idLib::Printf( "%i microseconds for 40 itterations\n", stop - start );
idLib::Printf( "%lli microseconds for 40 itterations\n", stop - start );
}

View file

@ -385,7 +385,7 @@ static void R_CheckPortableExtensions()
const char* badVideoCard = idLocalization::GetString( "#str_06780" );
if( glConfig.glVersion < 2.0f )
{
idLib::FatalError( badVideoCard );
idLib::FatalError( "%s", badVideoCard );
}
if( idStr::Icmpn( glConfig.renderer_string, "ATI ", 4 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "AMD ", 4 ) == 0 )

View file

@ -335,7 +335,7 @@ void idVertexCache::BeginBackEnd()
if( r_showVertexCache.GetBool() )
{
idLib::Printf( "%08d: %d allocations, %dkB vertex, %dkB index, %kB joint : %dkB vertex, %dkB index, %kB joint\n",
idLib::Printf( "%08d: %d allocations, %dkB vertex, %dkB index, %ikB joint : %dkB vertex, %dkB index, %ikB joint\n",
currentFrame, frameData[listNum].allocations,
frameData[listNum].vertexMemUsed.GetValue() / 1024,
frameData[listNum].indexMemUsed.GetValue() / 1024,

View file

@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
extern idCVar net_verboseSnapshot;
#define NET_VERBOSESNAPSHOT_PRINT if ( net_verboseSnapshot.GetInteger() > 0 ) idLib::Printf
#define NET_VERBOSESNAPSHOT_PRINT_LEVEL( X, Y ) if ( net_verboseSnapshot.GetInteger() >= ( X ) ) idLib::Printf( Y )
#define NET_VERBOSESNAPSHOT_PRINT_LEVEL( X, Y ) if ( net_verboseSnapshot.GetInteger() >= ( X ) ) idLib::Printf( "%s", Y )
/*
A snapshot contains a list of objects and their states

View file

@ -4048,9 +4048,9 @@ void idLobby::HandleBandwidhTestValue( int p, idBitMsg& msg )
idLib::Printf( "^3Finished Bandwidth test %s: \n", GetPeerName( p ) );
idLib::Printf( " Total time: %dms\n", totalTime );
idLib::Printf( " %sNum good packets: %d (%.2f%)\n", ( failedSeq ? "^1" : "^2" ), totalGoodSeq, pctPackets );
idLib::Printf( " %sTotal received bytes: %d (%.2f%)\n", ( failedByte ? "^1" : "^2" ), totalReceivedBytes, bytesPct );
idLib::Printf( " %sEffective downstream: %.2fkbs (host: %.2fkbs) -> %.2f%\n\n", ( failedRate ? "^1" : "^2" ), peerKBS, outgoingKBS, pctKBS );
idLib::Printf( " %sNum good packets: %d (%.2f%%)\n", ( failedSeq ? "^1" : "^2" ), totalGoodSeq, pctPackets );
idLib::Printf( " %sTotal received bytes: %d (%.2f%%)\n", ( failedByte ? "^1" : "^2" ), totalReceivedBytes, bytesPct );
idLib::Printf( " %sEffective downstream: %.2fkbs (host: %.2fkbs) -> %.2f%%\n\n", ( failedRate ? "^1" : "^2" ), peerKBS, outgoingKBS, pctKBS );
// If shittConnection(totalTime, totalGoodSeq/totalSeq, totalReceivedBytes/totalSentBytes)
// throttle this user: