Fix -Wparentheses warnings

suggest explicit braces to avoid ambiguous ‘else’
suggest parentheses around ‘&&’ within ‘||’
suggest parentheses around ‘-’ in operand of ‘&’
suggest parentheses around arithmetic in operand of ‘|’
equality comparison with extraneous parentheses

Functional change:
Proper HELLTIME check in Playerview due to missing parentheses.
This commit is contained in:
dhewg 2011-12-08 01:19:54 +01:00
parent 926b41f4a5
commit 9ab9bdea8b
11 changed files with 21 additions and 17 deletions

View file

@ -695,7 +695,7 @@ ID_INLINE bool idEntityPtr<type>::IsValid( void ) const {
template< class type > template< class type >
ID_INLINE type *idEntityPtr<type>::GetEntity( void ) const { ID_INLINE type *idEntityPtr<type>::GetEntity( void ) const {
int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ); int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 );
if ( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) ) { if ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) {
return static_cast<type *>( gameLocal.entities[ entityNum ] ); return static_cast<type *>( gameLocal.entities[ entityNum ] );
} }
return NULL; return NULL;

View file

@ -1377,7 +1377,7 @@ void FullscreenFX_DoubleVision::HighQuality() {
color.z = 0; color.z = 0;
} }
if ( !gameLocal.isMultiplayer && gameLocal.fast.time < player->inventory.powerupEndTime[ HELLTIME ] || gameLocal.fast.time < player->inventory.powerupEndTime[ INVULNERABILITY ]) { if ( !gameLocal.isMultiplayer && (gameLocal.fast.time < player->inventory.powerupEndTime[ HELLTIME ] || gameLocal.fast.time < player->inventory.powerupEndTime[ INVULNERABILITY ])) {
color.y = 0; color.y = 0;
color.z = 0; color.z = 0;
} }

View file

@ -876,7 +876,7 @@ void idAI::Event_CanBecomeSolid( void ) {
} }
#ifdef _D3XP #ifdef _D3XP
if ( spawnClearMoveables && hit->IsType( idMoveable::Type ) || hit->IsType( idBarrel::Type ) || hit->IsType( idExplodingBarrel::Type ) ) { if ( (spawnClearMoveables && hit->IsType( idMoveable::Type )) || (hit->IsType( idBarrel::Type ) || hit->IsType( idExplodingBarrel::Type) ) ) {
idVec3 push; idVec3 push;
push = hit->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin(); push = hit->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin();
push.z = 30.f; push.z = 30.f;

View file

@ -1479,11 +1479,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
/* we check the magic */ /* we check the magic */
if (err==UNZ_OK) if (err==UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
else if (uMagic!=0x02014b50) else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
}
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1559,11 +1560,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
else else
uSizeRead = extraFieldBufferSize; uSizeRead = extraFieldBufferSize;
if (lSeek!=0) if (lSeek!=0) {
if (fseek(s->file,lSeek,SEEK_CUR)==0) if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0; lSeek=0;
else else
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1584,11 +1586,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
else else
uSizeRead = commentBufferSize; uSizeRead = commentBufferSize;
if (lSeek!=0) if (lSeek!=0) {
if (fseek(s->file,lSeek,SEEK_CUR)==0) if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0; lSeek=0;
else else
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1783,11 +1786,12 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
return UNZ_ERRNO; return UNZ_ERRNO;
if (err==UNZ_OK) if (err==UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
else if (uMagic!=0x04034b50) else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
}
if (unzlocal_getShort(s->file,&uData) != UNZ_OK) if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1966,7 +1970,7 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
return UNZ_PARAMERROR; return UNZ_PARAMERROR;
if ((pfile_in_zip_read_info->read_buffer == NULL)) if (pfile_in_zip_read_info->read_buffer == NULL)
return UNZ_END_OF_LIST_OF_FILE; return UNZ_END_OF_LIST_OF_FILE;
if (len==0) if (len==0)
return 0; return 0;

View file

@ -628,7 +628,7 @@ ID_INLINE bool idEntityPtr<type>::IsValid( void ) const {
template< class type > template< class type >
ID_INLINE type *idEntityPtr<type>::GetEntity( void ) const { ID_INLINE type *idEntityPtr<type>::GetEntity( void ) const {
int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ); int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 );
if ( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) ) { if ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) {
return static_cast<type *>( gameLocal.entities[ entityNum ] ); return static_cast<type *>( gameLocal.entities[ entityNum ] );
} }
return NULL; return NULL;

View file

@ -515,7 +515,7 @@ int idBitMsg::ReadDeltaByteCounter( int oldValue ) const {
return oldValue; return oldValue;
} }
newValue = ReadBits( i ); newValue = ReadBits( i );
return ( oldValue & ~( ( 1 << i ) - 1 ) | newValue ); return ( (oldValue & ~( ( 1 << i ) - 1 ) ) | newValue );
} }
/* /*
@ -531,7 +531,7 @@ int idBitMsg::ReadDeltaShortCounter( int oldValue ) const {
return oldValue; return oldValue;
} }
newValue = ReadBits( i ); newValue = ReadBits( i );
return ( oldValue & ~( ( 1 << i ) - 1 ) | newValue ); return ( (oldValue & ~( ( 1 << i ) - 1 ) ) | newValue );
} }
/* /*
@ -547,7 +547,7 @@ int idBitMsg::ReadDeltaLongCounter( int oldValue ) const {
return oldValue; return oldValue;
} }
newValue = ReadBits( i ); newValue = ReadBits( i );
return ( oldValue & ~( ( 1 << i ) - 1 ) | newValue ); return ( ( oldValue & ~( ( 1 << i ) - 1 ) ) | newValue );
} }
/* /*

View file

@ -333,7 +333,7 @@ void *idHeap::Allocate16( const dword bytes ) {
common->FatalError( "malloc failure for %i", bytes ); common->FatalError( "malloc failure for %i", bytes );
} }
} }
alignedPtr = (byte *) ( ( (int) ptr ) + 15 & ~15 ); alignedPtr = (byte *) ( ( ( (int) ptr ) + 15) & ~15 );
if ( alignedPtr - ptr < 4 ) { if ( alignedPtr - ptr < 4 ) {
alignedPtr += 16; alignedPtr += 16;
} }

View file

@ -615,7 +615,7 @@ void idImage::GenerateImage( const byte *pic, int width, int height,
R_SetBorderTexels( (byte *)scaledBuffer, width, height, rgba ); R_SetBorderTexels( (byte *)scaledBuffer, width, height, rgba );
} }
if ( generatorFunction == NULL && ( depth == TD_BUMP && globalImages->image_writeNormalTGA.GetBool() || depth != TD_BUMP && globalImages->image_writeTGA.GetBool() ) ) { if ( generatorFunction == NULL && ( (depth == TD_BUMP && globalImages->image_writeNormalTGA.GetBool()) || (depth != TD_BUMP && globalImages->image_writeTGA.GetBool()) ) ) {
// Optionally write out the texture to a .tga // Optionally write out the texture to a .tga
char filename[MAX_IMAGE_NAME]; char filename[MAX_IMAGE_NAME];
ImageProgramStringToCompressedFileName( imgName, filename ); ImageProgramStringToCompressedFileName( imgName, filename );

View file

@ -271,7 +271,7 @@ void R_SetAlphaNormalDivergence( byte *in, int width, int height ) {
if ( yy == 0 && xx == 0 ) { if ( yy == 0 && xx == 0 ) {
continue; continue;
} }
byte *corner_p = in + ( ((y+yy)&(height-1)) * width + ((x+xx)&width-1) ) * 4; byte *corner_p = in + ( ((y+yy)&(height-1)) * width + ((x+xx)&(width-1)) ) * 4;
idVec3 corner; idVec3 corner;
corner[0] = ( corner_p[0] - 128 ) / 127; corner[0] = ( corner_p[0] - 128 ) / 127;
corner[1] = ( corner_p[1] - 128 ) / 127; corner[1] = ( corner_p[1] - 128 ) / 127;

View file

@ -1703,7 +1703,7 @@ static int add_clip( char *s, lwClip **clist, int *nclips )
clip->saturation.val = 1.0f; clip->saturation.val = 1.0f;
clip->gamma.val = 1.0f; clip->gamma.val = 1.0f;
if ( p = strstr( s, "(sequence)" )) { if ( (p = strstr( s, "(sequence)" ))) {
p[ -1 ] = 0; p[ -1 ] = 0;
clip->type = ID_ISEQ; clip->type = ID_ISEQ;
clip->source.seq.prefix = s; clip->source.seq.prefix = s;

View file

@ -137,7 +137,7 @@ void GL_SelectTexture( int unit ) {
return; return;
} }
if ( unit < 0 || unit >= glConfig.maxTextureUnits && unit >= glConfig.maxTextureImageUnits ) { if ( unit < 0 || (unit >= glConfig.maxTextureUnits && unit >= glConfig.maxTextureImageUnits) ) {
common->Warning( "GL_SelectTexture: unit = %i", unit ); common->Warning( "GL_SelectTexture: unit = %i", unit );
return; return;
} }