From 5a40208a05d19109f7d880fbd5b8ec84066ba8f6 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 5 Oct 2010 15:04:45 +0200 Subject: [PATCH] q3map2: fix some more warnings imported from netradiant, initial commit message: > fix some more warnings --- tools/quake3/common/cmdlib.c | 2 +- tools/quake3/common/polylib.c | 4 ++-- tools/quake3/common/threads.c | 2 +- tools/quake3/common/vfs.c | 2 ++ tools/quake3/q3map2/surface.c | 2 +- tools/quake3/q3map2/vis.c | 10 ++++++++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/quake3/common/cmdlib.c b/tools/quake3/common/cmdlib.c index dd8c21b3..b3bbcb6d 100644 --- a/tools/quake3/common/cmdlib.c +++ b/tools/quake3/common/cmdlib.c @@ -297,7 +297,7 @@ void Q_getwd( char *out ){ strcat( out, "\\" ); #else // Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow - getcwd( out, 256 ); + if( !getcwd ( out, 256 ) ) *out = 0; strcat( out, "/" ); #endif while ( out[i] != 0 ) diff --git a/tools/quake3/common/polylib.c b/tools/quake3/common/polylib.c index e4e93e79..b2b56a04 100644 --- a/tools/quake3/common/polylib.c +++ b/tools/quake3/common/polylib.c @@ -461,7 +461,7 @@ winding_t *BaseWindingForPlane( vec3_t normal, vec_t dist ){ ================== */ winding_t *CopyWinding( winding_t *w ){ - int size; + size_t size; winding_t *c; if ( !w ) { @@ -469,7 +469,7 @@ winding_t *CopyWinding( winding_t *w ){ } c = AllocWinding( w->numpoints ); - size = sizeof( *w ) + sizeof( *w->p ) * w->numpoints; + size = (size_t)sizeof( *w ) + sizeof( *w->p ) * w->numpoints; memcpy( c, w, size ); return c; } diff --git a/tools/quake3/common/threads.c b/tools/quake3/common/threads.c index 23a41655..f62432c9 100644 --- a/tools/quake3/common/threads.c +++ b/tools/quake3/common/threads.c @@ -551,7 +551,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){ for ( i = 0 ; i < numthreads ; i++ ) { /* Default pthread attributes: joinable & non-realtime scheduling */ - if ( pthread_create( &work_threads[i], NULL, (void*)func, (void*)i ) != 0 ) { + if ( pthread_create( &work_threads[i], NULL, (void*)func, (void*)(size_t)i ) != 0 ) { Error( "pthread_create failed" ); } } diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index 97b5da82..5f7433bc 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -289,6 +289,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ f = fopen( filename, "rb" ); if ( f == NULL ) { + fclose(f); return -1; } @@ -298,6 +299,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ *bufferptr = safe_malloc( len + 1 ); if ( *bufferptr == NULL ) { + fclose(f); return -1; } diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index 3813cb1c..e58134f5 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -297,7 +297,7 @@ void ClearSurface( mapDrawSurface_t *ds ){ void TidyEntitySurfaces( entity_t *e ){ int i, j, deleted; - mapDrawSurface_t *out, *in; + mapDrawSurface_t *out, *in = NULL; /* note it */ diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index 64107c71..2e9866e1 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -954,7 +954,10 @@ void LoadPortals( char *name ){ for ( k = 0 ; k < 3 ; k++ ) w->points[j][k] = v[k]; } - fscanf( f, "\n" ); + if ( fscanf( f, "\n" ) != 0) + { + // silence gcc warning + } // calc plane PlaneFromWinding( w, &plane ); @@ -1029,7 +1032,10 @@ void LoadPortals( char *name ){ for ( k = 0 ; k < 3 ; k++ ) w->points[j][k] = v[k]; } - fscanf( f, "\n" ); + if ( fscanf( f, "\n" ) != 0) + { + // silence gcc warning + } // calc plane PlaneFromWinding( w, &plane );