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 a1f72df989
commit 01545faf94
2 changed files with 21 additions and 0 deletions

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
/*
================