From 9ab9bdea8b64fc9e837deae9e13411fc6419ebbd Mon Sep 17 00:00:00 2001 From: dhewg Date: Thu, 8 Dec 2011 01:19:54 +0100 Subject: [PATCH] Fix -Wparentheses warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- neo/d3xp/Game_local.h | 2 +- neo/d3xp/PlayerView.cpp | 2 +- neo/d3xp/ai/AI_events.cpp | 2 +- neo/framework/Unzip.cpp | 14 +++++++++----- neo/game/Game_local.h | 2 +- neo/idlib/BitMsg.cpp | 6 +++--- neo/idlib/Heap.cpp | 2 +- neo/renderer/Image_load.cpp | 2 +- neo/renderer/Image_process.cpp | 2 +- neo/renderer/Model_lwo.cpp | 2 +- neo/renderer/tr_backend.cpp | 2 +- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/neo/d3xp/Game_local.h b/neo/d3xp/Game_local.h index 6e9173b3..bf9d6b2c 100644 --- a/neo/d3xp/Game_local.h +++ b/neo/d3xp/Game_local.h @@ -695,7 +695,7 @@ ID_INLINE bool idEntityPtr::IsValid( void ) const { template< class type > ID_INLINE type *idEntityPtr::GetEntity( void ) const { int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ); - if ( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) ) { + if ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) { return static_cast( gameLocal.entities[ entityNum ] ); } return NULL; diff --git a/neo/d3xp/PlayerView.cpp b/neo/d3xp/PlayerView.cpp index d869ed3d..4dfd258a 100644 --- a/neo/d3xp/PlayerView.cpp +++ b/neo/d3xp/PlayerView.cpp @@ -1377,7 +1377,7 @@ void FullscreenFX_DoubleVision::HighQuality() { 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.z = 0; } diff --git a/neo/d3xp/ai/AI_events.cpp b/neo/d3xp/ai/AI_events.cpp index a7183be5..f4c4af22 100644 --- a/neo/d3xp/ai/AI_events.cpp +++ b/neo/d3xp/ai/AI_events.cpp @@ -876,7 +876,7 @@ void idAI::Event_CanBecomeSolid( void ) { } #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; push = hit->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin(); push.z = 30.f; diff --git a/neo/framework/Unzip.cpp b/neo/framework/Unzip.cpp index ec9b8c5d..58bed4ce 100644 --- a/neo/framework/Unzip.cpp +++ b/neo/framework/Unzip.cpp @@ -1479,11 +1479,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file, /* we check the magic */ - if (err==UNZ_OK) + if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; + } if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; @@ -1559,11 +1560,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file, else uSizeRead = extraFieldBufferSize; - if (lSeek!=0) + if (lSeek!=0) { if (fseek(s->file,lSeek,SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; + } if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; @@ -1584,11 +1586,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file, else uSizeRead = commentBufferSize; - if (lSeek!=0) + if (lSeek!=0) { if (fseek(s->file,lSeek,SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; + } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; @@ -1783,11 +1786,12 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar, return UNZ_ERRNO; - if (err==UNZ_OK) + if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; + } if (unzlocal_getShort(s->file,&uData) != UNZ_OK) err=UNZ_ERRNO; @@ -1966,7 +1970,7 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len) 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; if (len==0) return 0; diff --git a/neo/game/Game_local.h b/neo/game/Game_local.h index e66b4d71..83ee1633 100644 --- a/neo/game/Game_local.h +++ b/neo/game/Game_local.h @@ -628,7 +628,7 @@ ID_INLINE bool idEntityPtr::IsValid( void ) const { template< class type > ID_INLINE type *idEntityPtr::GetEntity( void ) const { int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ); - if ( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) ) { + if ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) { return static_cast( gameLocal.entities[ entityNum ] ); } return NULL; diff --git a/neo/idlib/BitMsg.cpp b/neo/idlib/BitMsg.cpp index f6f3b7f2..ed8072c1 100644 --- a/neo/idlib/BitMsg.cpp +++ b/neo/idlib/BitMsg.cpp @@ -515,7 +515,7 @@ int idBitMsg::ReadDeltaByteCounter( int oldValue ) const { return oldValue; } 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; } 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; } newValue = ReadBits( i ); - return ( oldValue & ~( ( 1 << i ) - 1 ) | newValue ); + return ( ( oldValue & ~( ( 1 << i ) - 1 ) ) | newValue ); } /* diff --git a/neo/idlib/Heap.cpp b/neo/idlib/Heap.cpp index 0aca5c21..df3d6ccc 100644 --- a/neo/idlib/Heap.cpp +++ b/neo/idlib/Heap.cpp @@ -333,7 +333,7 @@ void *idHeap::Allocate16( const dword bytes ) { common->FatalError( "malloc failure for %i", bytes ); } } - alignedPtr = (byte *) ( ( (int) ptr ) + 15 & ~15 ); + alignedPtr = (byte *) ( ( ( (int) ptr ) + 15) & ~15 ); if ( alignedPtr - ptr < 4 ) { alignedPtr += 16; } diff --git a/neo/renderer/Image_load.cpp b/neo/renderer/Image_load.cpp index 10ea10a0..57141ea8 100644 --- a/neo/renderer/Image_load.cpp +++ b/neo/renderer/Image_load.cpp @@ -615,7 +615,7 @@ void idImage::GenerateImage( const byte *pic, int width, int height, 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 char filename[MAX_IMAGE_NAME]; ImageProgramStringToCompressedFileName( imgName, filename ); diff --git a/neo/renderer/Image_process.cpp b/neo/renderer/Image_process.cpp index b552d36a..4a468e23 100644 --- a/neo/renderer/Image_process.cpp +++ b/neo/renderer/Image_process.cpp @@ -271,7 +271,7 @@ void R_SetAlphaNormalDivergence( byte *in, int width, int height ) { if ( yy == 0 && xx == 0 ) { 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; corner[0] = ( corner_p[0] - 128 ) / 127; corner[1] = ( corner_p[1] - 128 ) / 127; diff --git a/neo/renderer/Model_lwo.cpp b/neo/renderer/Model_lwo.cpp index 1ae3f1ba..89bc6c5a 100644 --- a/neo/renderer/Model_lwo.cpp +++ b/neo/renderer/Model_lwo.cpp @@ -1703,7 +1703,7 @@ static int add_clip( char *s, lwClip **clist, int *nclips ) clip->saturation.val = 1.0f; clip->gamma.val = 1.0f; - if ( p = strstr( s, "(sequence)" )) { + if ( (p = strstr( s, "(sequence)" ))) { p[ -1 ] = 0; clip->type = ID_ISEQ; clip->source.seq.prefix = s; diff --git a/neo/renderer/tr_backend.cpp b/neo/renderer/tr_backend.cpp index bf77fdf7..fb4a39ba 100644 --- a/neo/renderer/tr_backend.cpp +++ b/neo/renderer/tr_backend.cpp @@ -137,7 +137,7 @@ void GL_SelectTexture( int unit ) { 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 ); return; }