Get rid of some compiler warnings

GCC had shitloads of superfluous warnings wherever List.h and Str.h were
included.. get rid of them by using #pragma GCC diagnostic at some places
in List.h and Str.h.
Also add some casts, initialize some variables for other warnings
This commit is contained in:
Daniel Gibson 2012-09-16 23:53:28 +02:00
parent aedc76b50e
commit 3202f0aa0f
4 changed files with 25 additions and 3 deletions

View file

@ -467,7 +467,7 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
{
unz_s* s;
unz_file_info file_info;
unz_file_info_internal file_info_internal;
unz_file_info_internal file_info_internal = {0};
int err=UNZ_OK;
uLong uMagic;
long lSeek=0;
@ -774,7 +774,7 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
uInt *psize_local_extrafield)
{
uLong uMagic,uData,uFlags = 0;
uLong size_filename;
uLong size_filename = 0;
uLong size_extra_field;
int err=UNZ_OK;

View file

@ -503,6 +503,10 @@ ID_INLINE idStr::operator const char *( void ) const {
return c_str();
}
#pragma GCC diagnostic push
// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
// (X - c) > X is always false [-Wstrict-overflow]"
#pragma GCC diagnostic ignored "-Wstrict-overflow"
ID_INLINE char idStr::operator[]( int index ) const {
assert( ( index >= 0 ) && ( index <= len ) );
return data[ index ];
@ -512,6 +516,7 @@ ID_INLINE char &idStr::operator[]( int index ) {
assert( ( index >= 0 ) && ( index <= len ) );
return data[ index ];
}
#pragma GCC diagnostic pop
ID_INLINE void idStr::operator=( const idStr &text ) {
int l;
@ -912,12 +917,17 @@ ID_INLINE idStr idStr::Left( int len ) const {
return Mid( 0, len );
}
#pragma GCC diagnostic push
// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
// (X - c) > X is always false [-Wstrict-overflow]"
#pragma GCC diagnostic ignored "-Wstrict-overflow"
ID_INLINE idStr idStr::Right( int len ) const {
if ( len >= Length() ) {
return *this;
}
return Mid( Length() - len, len );
}
#pragma GCC diagnostic pop
ID_INLINE void idStr::Strip( const char c ) {
StripLeading( c );

View file

@ -356,6 +356,10 @@ Allocates memory for the amount of elements requested while keeping the contents
Contents are copied using their = operator so that data is correnctly instantiated.
================
*/
#pragma GCC diagnostic push
// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
// (X - c) > X is always false [-Wstrict-overflow]"
#pragma GCC diagnostic ignored "-Wstrict-overflow"
template< class type >
ID_INLINE void idList<type>::Resize( int newsize ) {
type *temp;
@ -376,6 +380,7 @@ ID_INLINE void idList<type>::Resize( int newsize ) {
temp = list;
size = newsize;
if ( size < num ) {
num = size;
}
@ -391,6 +396,7 @@ ID_INLINE void idList<type>::Resize( int newsize ) {
delete[] temp;
}
}
#pragma GCC diagnostic pop
/*
================
@ -549,6 +555,10 @@ ID_INLINE idList<type> &idList<type>::operator=( const idList<type> &other ) {
return *this;
}
#pragma GCC diagnostic push
// shut up GCC's stupid "warning: assuming signed overflow does not occur when assuming that
// (X - c) > X is always false [-Wstrict-overflow]"
#pragma GCC diagnostic ignored "-Wstrict-overflow"
/*
================
idList<type>::operator[] const
@ -580,6 +590,7 @@ ID_INLINE type &idList<type>::operator[]( int index ) {
return list[ index ];
}
#pragma GCC diagnostic pop
/*
================

View file

@ -363,7 +363,8 @@ void idTextureLevel::UpdateTile( int localX, int localY, int globalX, int global
if ( idMegaTexture::r_showMegaTextureLabels.GetBool() ) {
// put a color marker in it
byte color[4] = { 255 * localX / TILE_PER_LEVEL, 255 * localY / TILE_PER_LEVEL, 0, 0 };
// localX and localY are < TILE_PER_LEVEL => that fits perfectly into a byte.
byte color[4] = { (byte)(255 * localX / TILE_PER_LEVEL), (byte)(255 * localY / TILE_PER_LEVEL), 0, 0 };
for ( int x = 0 ; x < 8 ; x++ ) {
for ( int y = 0 ; y < 8 ; y++ ) {
*(int *)&data[ ( ( y + TILE_SIZE/2 - 4 ) * TILE_SIZE + x + TILE_SIZE/2 - 4 ) * 4 ] = *(int *)color;