From 0311de363b4b54196e89d254fefbcb79d39342af Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 7 Aug 2017 21:51:59 +1000 Subject: [PATCH] Remove -Wno-sign-compare --- CMakeLists.txt | 1 - contrib/bobtoolz/misc.cpp | 2 +- contrib/prtview/portals.cpp | 14 +++++++------- libs/generic/constant.h | 1 + libs/splines/q_shared.cpp | 17 +++++++++-------- libs/splines/q_shared.h | 8 +++++--- plugins/iqmmodel/iqm.cpp | 4 ++-- plugins/mapq3/plugin.cpp | 4 ++-- radiant/patch.cpp | 15 ++++++--------- radiant/undo.cpp | 2 +- tools/quake3/common/trilib.c | 2 +- tools/quake3/q3map2/light_ydnar.c | 2 +- tools/quake3/q3map2/q3map2.h | 2 +- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ee2a34f..00e98145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,6 @@ addflags("-pedantic") addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown -addflags("-Wno-sign-compare") addflags("-Wno-unused-function") addflags("-Wno-unused-variable") addflags("-Wno-unused-parameter") diff --git a/contrib/bobtoolz/misc.cpp b/contrib/bobtoolz/misc.cpp index 977879f5..202065fc 100644 --- a/contrib/bobtoolz/misc.cpp +++ b/contrib/bobtoolz/misc.cpp @@ -129,7 +129,7 @@ char* TranslateString( char *buf ){ std::size_t l = strlen( buf ); char* out = buf2; - for ( int i = 0 ; i < l ; i++ ) + for ( std::size_t i = 0 ; i < l ; i++ ) { if ( buf[i] == '\n' ) { *out++ = '\r'; diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index c9b80176..0522fe40 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -603,7 +603,7 @@ void CPortalsDrawSolid::render( RenderStateFlags state ) const { } void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const { - for ( int n = 0; n < portals.portal_count; n++ ) + for ( unsigned int n = 0; n < portals.portal_count; n++ ) { if ( portals.lines == 2 && !portals.portal[n].hint ) { continue; @@ -613,26 +613,26 @@ void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const { if ( clip.min[0] < portals.portal[n].min[0] ) { continue; } - else if ( clip.min[1] < portals.portal[n].min[1] ) { + if ( clip.min[1] < portals.portal[n].min[1] ) { continue; } - else if ( clip.min[2] < portals.portal[n].min[2] ) { + if ( clip.min[2] < portals.portal[n].min[2] ) { continue; } - else if ( clip.max[0] > portals.portal[n].max[0] ) { + if ( clip.max[0] > portals.portal[n].max[0] ) { continue; } - else if ( clip.max[1] > portals.portal[n].max[1] ) { + if ( clip.max[1] > portals.portal[n].max[1] ) { continue; } - else if ( clip.max[2] > portals.portal[n].max[2] ) { + if ( clip.max[2] > portals.portal[n].max[2] ) { continue; } } glBegin( GL_LINE_LOOP ); - for ( int p = 0; p < portals.portal[n].point_count; p++ ) + for ( unsigned int p = 0; p < portals.portal[n].point_count; p++ ) glVertex3fv( portals.portal[n].inner_point[p].p ); glEnd(); diff --git a/libs/generic/constant.h b/libs/generic/constant.h index 83817947..ab64ec39 100644 --- a/libs/generic/constant.h +++ b/libs/generic/constant.h @@ -43,6 +43,7 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const #define TYPE_CONSTANT( name, value, type ) struct name ## _CONSTANT_ { typedef type Value; static Value evaluate() { return value; } }; typedef ConstantWrapper name #define STRING_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, const char* ) #define INTEGER_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, int ) +#define UINT_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, unsigned int ) STRING_CONSTANT( EmptyString, "" ); diff --git a/libs/splines/q_shared.cpp b/libs/splines/q_shared.cpp index 204d980d..1df4dfcd 100644 --- a/libs/splines/q_shared.cpp +++ b/libs/splines/q_shared.cpp @@ -546,7 +546,7 @@ char* Q_strrchr( const char* string, int c ){ Safe strncpy that ensures a trailing zero ============= */ -void Q_strncpyz( char *dest, const char *src, int destsize ) { +void Q_strncpyz( char *dest, const char *src, std::size_t destsize ) { if ( !src ) { Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" ); } @@ -633,10 +633,8 @@ char *Q_strupr( char *s1 ) { // never goes past bounds or leaves without a terminating 0 -void Q_strcat( char *dest, int size, const char *src ) { - int l1; - - l1 = strlen( dest ); +void Q_strcat( char *dest, std::size_t size, const char *src ) { + auto l1 = strlen( dest ); if ( l1 >= size ) { Com_Error( ERR_FATAL, "Q_strcat: already overflowed" ); } @@ -689,14 +687,17 @@ char *Q_CleanStr( char *string ) { } -void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) { - int len; +void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... ) { va_list argptr; char bigbuffer[32000]; // big, but small enough to fit in PPC stack va_start( argptr,fmt ); - len = vsprintf( bigbuffer,fmt,argptr ); + int ret = vsprintf( bigbuffer,fmt,argptr ); va_end( argptr ); + if ( ret < 0 ) { + Com_Error(ERR_FATAL, "Com_sprintf: vsprintf failed"); + } + auto len = static_cast(ret); if ( len >= sizeof( bigbuffer ) ) { Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" ); } diff --git a/libs/splines/q_shared.h b/libs/splines/q_shared.h index 61f1024b..09a20b81 100644 --- a/libs/splines/q_shared.h +++ b/libs/splines/q_shared.h @@ -65,6 +65,8 @@ #include #include #include +#include + #ifdef WIN32 // mac doesn't have malloc.h #include // for _alloca() #endif @@ -591,7 +593,7 @@ void Com_Parse3DMatrix( const char *( *buf_p ), int z, int y, int x, float *m ); extern "C" { #endif -void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ); +void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... ); // mode parm for FS_FOpenFile @@ -624,8 +626,8 @@ char *Q_strupr( char *s1 ); char *Q_strrchr( const char* string, int c ); // buffer size safe library replacements -void Q_strncpyz( char *dest, const char *src, int destsize ); -void Q_strcat( char *dest, int size, const char *src ); +void Q_strncpyz( char *dest, const char *src, std::size_t destsize ); +void Q_strcat( char *dest, std::size_t size, const char *src ); // strlen that discounts Quake color sequences int Q_PrintStrlen( const char *string ); diff --git a/plugins/iqmmodel/iqm.cpp b/plugins/iqmmodel/iqm.cpp index c1f7db89..d7c4bf4b 100644 --- a/plugins/iqmmodel/iqm.cpp +++ b/plugins/iqmmodel/iqm.cpp @@ -192,7 +192,7 @@ void IQMSurface_read(Model& model, const byte* buffer, ArchiveFile& file) int ofs_position = -1, ofs_st = -1, ofs_normal = -1; PointerInputStream vaStream (buffer + header.ofs_vertexarrays); - for (int i = 0; i < header.num_vertexarrays; i++) + for (unsigned int i = 0; i < header.num_vertexarrays; i++) { iqmvertexarray_t va; istream_read_iqmVertexarray (vaStream, va); @@ -238,7 +238,7 @@ void IQMSurface_read(Model& model, const byte* buffer, ArchiveFile& file) } PointerInputStream triangleStream(buffer + header.ofs_triangles); - for(int i = 0; i < header.num_triangles; ++i) + for(unsigned int i = 0; i < header.num_triangles; ++i) { iqmTriangle_t triangle; istream_read_iqmTriangle(triangleStream, triangle); diff --git a/plugins/mapq3/plugin.cpp b/plugins/mapq3/plugin.cpp index b107f583..766a7eba 100644 --- a/plugins/mapq3/plugin.cpp +++ b/plugins/mapq3/plugin.cpp @@ -71,7 +71,7 @@ MapDoom3Dependencies& m_dependencies; public: typedef MapFormat Type; STRING_CONSTANT( Name, "mapdoom3" ); -INTEGER_CONSTANT( MapVersion, 2 ); +UINT_CONSTANT( MapVersion, 2 ); MapDoom3API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){ GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "doom3 maps", "*.map" ) ); @@ -142,7 +142,7 @@ MapDoom3Dependencies& m_dependencies; public: typedef MapFormat Type; STRING_CONSTANT( Name, "mapquake4" ); -INTEGER_CONSTANT( MapVersion, 3 ); +UINT_CONSTANT( MapVersion, 3 ); MapQuake4API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){ GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake4 maps", "*.map" ) ); diff --git a/radiant/patch.cpp b/radiant/patch.cpp index b31def46..dca55b79 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1357,14 +1357,13 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; float f = 1 / cos( M_PI / n ); - for ( i = 0; i < width; ++i ) + for ( std::size_t i = 0; i < width; ++i ) { float angle = ( M_PI * i ) / n; // 0 to 2pi float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); float y = vPos[1][1] + ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); - for ( j = 0; j < height; ++j ) + for ( std::size_t j = 0; j < height; ++j ) { float z = vPos[0][2] + ( vPos[2][2] - vPos[0][2] ) * ( j / (float)( height - 1 ) ); PatchControl *v; @@ -1383,12 +1382,11 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; float f = 1 / cos( M_PI / n ); - for ( i = 0; i < width; ++i ) + for ( std::size_t i = 0; i < width; ++i ) { float angle = ( M_PI * i ) / n; - for ( j = 0; j < height; ++j ) + for ( std::size_t j = 0; j < height; ++j ) { float x = vPos[1][0] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); float y = vPos[1][1] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); @@ -1410,13 +1408,12 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; float f = 1 / cos( M_PI / n ); float g = 1 / cos( M_PI / ( 2 * m ) ); - for ( i = 0; i < width; ++i ) + for ( std::size_t i = 0; i < width; ++i ) { float angle = ( M_PI * i ) / n; - for ( j = 0; j < height; ++j ) + for ( std::size_t j = 0; j < height; ++j ) { float angle2 = ( M_PI * j ) / ( 2 * m ); float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * sin( angle2 ) * ( ( j & 1 ) ? g : 1.0f ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); diff --git a/radiant/undo.cpp b/radiant/undo.cpp index 9910fb98..eb536d88 100644 --- a/radiant/undo.cpp +++ b/radiant/undo.cpp @@ -57,7 +57,7 @@ DebugScopeTimer( const char* operation ) class RadiantUndoSystem : public UndoSystem { -INTEGER_CONSTANT( MAX_UNDO_LEVELS, 1024 ); +UINT_CONSTANT( MAX_UNDO_LEVELS, 1024 ); class Snapshot { diff --git a/tools/quake3/common/trilib.c b/tools/quake3/common/trilib.c index 8b063b0f..d3ec168a 100644 --- a/tools/quake3/common/trilib.c +++ b/tools/quake3/common/trilib.c @@ -61,7 +61,7 @@ typedef struct { static void ByteSwapTri( tf_triangle *tri ){ - int i; + unsigned int i; for ( i = 0 ; i < sizeof( tf_triangle ) / 4 ; i++ ) { diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 34c22833..b63d14b2 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -3183,7 +3183,7 @@ void IlluminateVertexes( int num ){ determines opaque brushes in the world and find sky shaders for sunlight calculations */ -void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ){ +void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all ){ int i, j, b; unsigned int compileFlags, allCompileFlags; qboolean inside; diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 44cd0b58..7b677c83 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1825,7 +1825,7 @@ void FloodLightRawLightmap( int num ); void IlluminateRawLightmap( int num ); void IlluminateVertexes( int num ); -void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ); +void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all ); void SetupBrushes( void ); void SetupClusters( void ); qboolean ClusterVisible( int a, int b ); -- 2.39.2