Skip to content

Commit

Permalink
Some signed-unsigned comparisons fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Boton committed Nov 26, 2011
1 parent 44bf0c6 commit 5b76c99
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion neo/d3xp/AF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ bool idAF::Load( idEntity *ent, const char *fileName ) {
idAFConstraint *constraint = physicsObj.GetConstraint( i );
for ( j = 0; j < file->constraints.Num(); j++ ) {
if ( file->constraints[j]->name.Icmp( constraint->GetName() ) == 0 &&
file->constraints[j]->type == constraint->GetType() ) {
(int)file->constraints[j]->type == (int)constraint->GetType() ) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion neo/d3xp/gamesys/TypeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const char *idTypeInfoTools::OutputString( const char *string ) {
static int index = 0;
static char buffers[4][16384];
char *out;
int i, c;
unsigned int i, c;

out = buffers[index];
index = ( index + 1 ) & 3;
Expand Down
4 changes: 2 additions & 2 deletions neo/d3xp/script/Script_Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ idScriptObject::Restore
*/
void idScriptObject::Restore( idRestoreGame *savefile ) {
idStr typeName;
size_t size;
int size;

savefile->ReadString( typeName );

Expand Down Expand Up @@ -1319,7 +1319,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
//
def->value.bytePtr = &variables[ numVariables ];
numVariables += def->TypeDef()->Size();
if ( numVariables > sizeof( variables ) ) {
if ( (unsigned int)numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%zu bytes)", sizeof( variables ) ) );
}

Expand Down
6 changes: 3 additions & 3 deletions neo/framework/DeclManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ BuildHuffmanCode_r
void BuildHuffmanCode_r( huffmanNode_t *node, huffmanCode_t code, huffmanCode_t codes[MAX_HUFFMAN_SYMBOLS] ) {
if ( node->symbol == -1 ) {
huffmanCode_t newCode = code;
assert( code.numBits < sizeof( codes[0].bits ) * 8 );
assert( (size_t)code.numBits < sizeof( codes[0].bits ) * 8 );
newCode.numBits++;
if ( code.numBits > maxHuffmanBits ) {
maxHuffmanBits = newCode.numBits;
Expand All @@ -369,7 +369,7 @@ void BuildHuffmanCode_r( huffmanNode_t *node, huffmanCode_t code, huffmanCode_t
newCode.bits[code.numBits >> 5] |= 1 << ( code.numBits & 31 );
BuildHuffmanCode_r( node->children[1], newCode, codes );
} else {
assert( code.numBits <= sizeof( codes[0].bits ) * 8 );
assert( (size_t)code.numBits <= sizeof( codes[0].bits ) * 8 );
codes[node->symbol] = code;
}
}
Expand Down Expand Up @@ -1975,7 +1975,7 @@ bool idDeclLocal::ReplaceSourceFileText( void ) {
file->Read( buffer, oldFileLength );
fileSystem->CloseFile( file );

if ( MD5_BlockChecksum( buffer, oldFileLength ) != sourceFile->checksum ) {
if ( MD5_BlockChecksum( buffer, oldFileLength ) != (unsigned int)sourceFile->checksum ) {
Mem_Free( buffer );
common->Warning( "The file %s has been modified outside of the engine.", GetFileName() );
return false;
Expand Down
2 changes: 1 addition & 1 deletion neo/framework/KeyInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ idKeyInput::ArgCompletion_KeyName
*/
void idKeyInput::ArgCompletion_KeyName( const idCmdArgs &args, void(*callback)( const char *s ) ) {
keyname_t *kn;
int i;
unsigned int i;

for( i = 0; i < sizeof( unnamedkeys ) - 1; i++ ) {
callback( va( "%s %c", args.Argv( 0 ), unnamedkeys[ i ] ) );
Expand Down
2 changes: 1 addition & 1 deletion neo/framework/async/MsgChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ bool idMsgChannel::Process( const netadr_t from, int time, idBitMsg &msg, int &s
}

// copy the fragment to the fragment buffer
if ( fragLength < 0 || fragLength > msg.GetRemaingData() || fragmentLength + fragLength > sizeof( fragmentBuffer ) ) {
if ( fragLength < 0 || fragLength > msg.GetRemaingData() || (unsigned int)(fragmentLength + fragLength) > sizeof( fragmentBuffer ) ) {
if ( net_channelShowDrop.GetBool() || net_channelShowPackets.GetBool() ) {
common->Printf( "%s: illegal fragment length\n", Sys_NetAdrToString( remoteAddress ) );
}
Expand Down
2 changes: 1 addition & 1 deletion neo/game/AF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ bool idAF::Load( idEntity *ent, const char *fileName ) {
idAFConstraint *constraint = physicsObj.GetConstraint( i );
for ( j = 0; j < file->constraints.Num(); j++ ) {
if ( file->constraints[j]->name.Icmp( constraint->GetName() ) == 0 &&
file->constraints[j]->type == constraint->GetType() ) {
(int)file->constraints[j]->type == (int)constraint->GetType() ) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion neo/game/gamesys/TypeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const char *idTypeInfoTools::OutputString( const char *string ) {
static int index = 0;
static char buffers[4][16384];
char *out;
int i, c;
unsigned int i, c;

out = buffers[index];
index = ( index + 1 ) & 3;
Expand Down
4 changes: 2 additions & 2 deletions neo/game/script/Script_Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ idScriptObject::Restore
*/
void idScriptObject::Restore( idRestoreGame *savefile ) {
idStr typeName;
size_t size;
int size;

savefile->ReadString( typeName );

Expand Down Expand Up @@ -1319,7 +1319,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
//
def->value.bytePtr = &variables[ numVariables ];
numVariables += def->TypeDef()->Size();
if ( numVariables > sizeof( variables ) ) {
if ( (unsigned int)numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%zu bytes)", sizeof( variables ) ) );
}

Expand Down
4 changes: 2 additions & 2 deletions neo/idlib/BitMsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ void idBitMsgDelta::WriteData( const void *data, int length ) {
changed = true;
} else {
byte baseData[MAX_DATA_BUFFER];
assert( length < sizeof( baseData ) );
assert( (unsigned int)length < sizeof( baseData ) );
base->ReadData( baseData, length );
if ( memcmp( data, baseData, length ) == 0 ) {
writeDelta->WriteBits( 0, 1 );
Expand Down Expand Up @@ -946,7 +946,7 @@ void idBitMsgDelta::ReadData( void *data, int length ) const {
changed = true;
} else {
char baseData[MAX_DATA_BUFFER];
assert( length < sizeof( baseData ) );
assert( (unsigned int)length < sizeof( baseData ) );
base->ReadData( baseData, length );
if ( !readDelta || readDelta->ReadBits( 1 ) == 0 ) {
memcpy( data, baseData, length );
Expand Down
2 changes: 1 addition & 1 deletion neo/idlib/CmdArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void idCmdArgs::TokenizeString( const char *text, bool keepAsStrings ) {

len = token.Length();

if ( totalLen + len + 1 > sizeof( tokenized ) ) {
if ( (unsigned int)(totalLen + len + 1) > sizeof( tokenized ) ) {
return; // this is usually something malicious
}

Expand Down
4 changes: 2 additions & 2 deletions neo/idlib/Heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ void *idHeap::Allocate16( const dword bytes ) {
}
}
alignedPtr = (byte *) ( ( (size_t) ptr ) + 15 & ~15 );
if ( alignedPtr - ptr < sizeof(size_t) ) {
if ( (size_t)(alignedPtr - ptr) < sizeof(size_t) ) {
alignedPtr += 16;
}
*((long *)(alignedPtr - sizeof(size_t))) = (size_t) ptr;
*((size_t *)(alignedPtr - sizeof(size_t))) = (size_t) ptr;
return (void *) alignedPtr;
}

Expand Down
2 changes: 1 addition & 1 deletion neo/idlib/Str.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ int idStr::snPrintf( char *dest, int size, const char *fmt, ...) {
va_start( argptr, fmt );
len = vsprintf( buffer, fmt, argptr );
va_end( argptr );
if ( len >= sizeof( buffer ) ) {
if ( (unsigned int)len >= sizeof( buffer ) ) {
idLib::common->Error( "idStr::snPrintf: overflowed buffer" );
}
if ( len >= size ) {
Expand Down
4 changes: 2 additions & 2 deletions neo/idlib/geometry/Surface_SweptSpline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void idSurface_SweptSpline::Tessellate( const int splineSubdivisions, const int

// calculate the points and first derivatives for the swept spline
totalTime = sweptSpline->GetTime( sweptSpline->GetNumValues() - 1 ) - sweptSpline->GetTime( 0 ) + sweptSpline->GetCloseTime();
sweptSplineDiv = sweptSpline->GetBoundaryType() == idCurve_Spline<idVec3>::BT_CLOSED ? sweptSplineSubdivisions : sweptSplineSubdivisions - 1;
sweptSplineDiv = (int)sweptSpline->GetBoundaryType() == (int)idCurve_Spline<idVec3>::BT_CLOSED ? sweptSplineSubdivisions : sweptSplineSubdivisions - 1;
baseOffset = (splineSubdivisions-1) * sweptSplineSubdivisions;
for ( i = 0; i < sweptSplineSubdivisions; i++ ) {
t = totalTime * i / sweptSplineDiv;
Expand All @@ -172,7 +172,7 @@ void idSurface_SweptSpline::Tessellate( const int splineSubdivisions, const int

// sweep the spline
totalTime = spline->GetTime( spline->GetNumValues() - 1 ) - spline->GetTime( 0 ) + spline->GetCloseTime();
splineDiv = spline->GetBoundaryType() == idCurve_Spline<idVec3>::BT_CLOSED ? splineSubdivisions : splineSubdivisions - 1;
splineDiv = (int)spline->GetBoundaryType() == (int)idCurve_Spline<idVec3>::BT_CLOSED ? splineSubdivisions : splineSubdivisions - 1;
splineMat.Identity();
for ( i = 0; i < splineSubdivisions; i++ ) {
t = totalTime * i / splineDiv;
Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class idImage {

// data commonly accessed is grouped here
static const int TEXTURE_NOT_LOADED = -1;
GLuint texnum; // gl texture binding, will be TEXTURE_NOT_LOADED if not loaded
GLint texnum; // gl texture binding, will be TEXTURE_NOT_LOADED if not loaded
textureType_t type;
int frameUsed; // for texture usage in frame statistics
int bindCount; // incremented each bind
Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/Image_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static void LoadBMP( const char *name, byte **pic, int *width, int *height, ID_T
int row, column;
byte *buf_p;
byte *buffer;
int length;
unsigned int length;
BMPHeader_t bmpHeader;
byte *bmpRGBA;

Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/Image_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ void idImage::StartBackgroundImageLoad() {
}
bgl.file.position = 0;
bgl.file.length = bgl.f->Length();
if ( bgl.file.length < sizeof( ddsFileHeader_t ) ) {
if ( (unsigned int)bgl.file.length < sizeof( ddsFileHeader_t ) ) {
common->Warning( "idImageManager::StartBackgroundImageLoad: %s had a bad file length", imgName.c_str() );
return;
}
Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/Image_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ bool idImage::CheckPrecompressedImage( bool fullLoad ) {
}

int len = f->Length();
if ( len < sizeof( ddsFileHeader_t ) ) {
if ( (unsigned int)len < sizeof( ddsFileHeader_t ) ) {
fileSystem->CloseFile( f );
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion neo/sound/snd_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ int idSampleDecoderLocal::DecodePCM( idSoundSample *sample, int sampleOffset44k,
return 0;
}

if ( size - pos < sampleCount * sizeof( short ) ) {
if ( (unsigned int)(size - pos) < sampleCount * sizeof( short ) ) {
readSamples = ( size - pos ) / sizeof( short );
} else {
readSamples = sampleCount;
Expand Down

0 comments on commit 5b76c99

Please sign in to comment.