From: Rudolf Polzer <divverent@alientrap.org> Date: Tue, 5 Oct 2010 13:04:45 +0000 (+0200) Subject: fix some more warnings X-Git-Tag: xonotic-v0.5.0~197 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d5a9782200fa1447fc8de8705a2183ecd14db2b0;p=xonotic%2Fnetradiant.git fix some more warnings --- diff --git a/libs/ddslib/ddslib.c b/libs/ddslib/ddslib.c index bf1a9f15..424faeea 100644 --- a/libs/ddslib/ddslib.c +++ b/libs/ddslib/ddslib.c @@ -523,7 +523,7 @@ static int DDSDecompressDXT1( ddsBuffer_t *dds, int width, int height, unsigned for( y = 0; y < yBlocks; y++ ) { /* 8 bytes per block */ - block = (ddsColorBlock_t*) ((unsigned int) dds->data + y * xBlocks * 8); + block = (ddsColorBlock_t*) ((char *) dds->data + y * xBlocks * 8); /* walk x */ for( x = 0; x < xBlocks; x++, block++ ) @@ -569,7 +569,7 @@ static int DDSDecompressDXT3( ddsBuffer_t *dds, int width, int height, unsigned for( y = 0; y < yBlocks; y++ ) { /* 8 bytes per block, 1 block for alpha, 1 block for color */ - block = (ddsColorBlock_t*) ((unsigned int) dds->data + y * xBlocks * 16); + block = (ddsColorBlock_t*) ((char *) dds->data + y * xBlocks * 16); /* walk x */ for( x = 0; x < xBlocks; x++, block++ ) @@ -625,7 +625,7 @@ static int DDSDecompressDXT5( ddsBuffer_t *dds, int width, int height, unsigned for( y = 0; y < yBlocks; y++ ) { /* 8 bytes per block, 1 block for alpha, 1 block for color */ - block = (ddsColorBlock_t*) ((unsigned int) dds->data + y * xBlocks * 16); + block = (ddsColorBlock_t*) ((char *) dds->data + y * xBlocks * 16); /* walk x */ for( x = 0; x < xBlocks; x++, block++ ) diff --git a/libs/picomodel/lwo/lwob.c b/libs/picomodel/lwo/lwob.c index 2d0522d5..f12e3a36 100644 --- a/libs/picomodel/lwo/lwob.c +++ b/libs/picomodel/lwo/lwob.c @@ -563,7 +563,7 @@ int lwGetPolygons5( picoMemStream_t *fp, int cksize, lwPolygonList *plist, int p bp += 2; } j -= 1; - pp->surf = ( lwSurface * ) j; + pp->surf = ( lwSurface * ) (size_t) j; pp++; pv += nv; diff --git a/libs/picomodel/lwo/pntspols.c b/libs/picomodel/lwo/pntspols.c index a7f54d25..31475819 100644 --- a/libs/picomodel/lwo/pntspols.c +++ b/libs/picomodel/lwo/pntspols.c @@ -353,7 +353,7 @@ int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist, } for ( i = 0; i < polygon->count; i++ ) { - index = ( int ) polygon->pol[ i ].surf; + index = ( size_t ) polygon->pol[ i ].surf; if ( index < 0 || index > tlist->count ) return 0; if ( !s[ index ] ) { s[ index ] = lwDefaultSurface(); @@ -527,7 +527,7 @@ int lwGetPolygonTags( picoMemStream_t *fp, int cksize, lwTagList *tlist, if ( rlen < 0 || rlen > cksize ) return 0; switch ( type ) { - case ID_SURF: plist->pol[ i ].surf = ( lwSurface * ) j; break; + case ID_SURF: plist->pol[ i ].surf = ( lwSurface * ) (size_t) j; break; case ID_PART: plist->pol[ i ].part = j; break; case ID_SMGP: plist->pol[ i ].smoothgrp = j; break; } diff --git a/tools/quake3/common/cmdlib.c b/tools/quake3/common/cmdlib.c index fac9bdbb..5168d233 100644 --- a/tools/quake3/common/cmdlib.c +++ b/tools/quake3/common/cmdlib.c @@ -336,7 +336,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 21067ca2..fc8805e7 100644 --- a/tools/quake3/common/polylib.c +++ b/tools/quake3/common/polylib.c @@ -282,11 +282,11 @@ CopyWinding */ winding_t *CopyWinding (winding_t *w) { - int size; + size_t size; winding_t *c; c = AllocWinding (w->numpoints); - size = (int)((winding_t *)0)->p[w->numpoints]; + size = (size_t)((winding_t *)NULL)->p[w->numpoints]; memcpy (c, w, size); return c; } diff --git a/tools/quake3/common/threads.c b/tools/quake3/common/threads.c index a486abaf..7f404a4f 100644 --- a/tools/quake3/common/threads.c +++ b/tools/quake3/common/threads.c @@ -565,7 +565,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], &attr, (void*)func, (void*)i) != 0) + if(pthread_create(&work_threads[i], &attr, (void*)func, (void*)(size_t)i) != 0) Error("pthread_create failed"); } for (i=0 ; i<numthreads ; i++) diff --git a/tools/quake3/common/unzip.c b/tools/quake3/common/unzip.c index 41b09cb3..1e2be2be 100644 --- a/tools/quake3/common/unzip.c +++ b/tools/quake3/common/unzip.c @@ -1261,7 +1261,8 @@ static int unzlocal_getShort (FILE* fin, uLong *pX) { short v; - fread( &v, sizeof(v), 1, fin ); + if(fread( &v, sizeof(v), 1, fin ) != 1) + return UNZ_EOF; *pX = __LittleShort( v); return UNZ_OK; @@ -1290,7 +1291,8 @@ static int unzlocal_getLong (FILE *fin, uLong *pX) { int v; - fread( &v, sizeof(v), 1, fin ); + if(fread( &v, sizeof(v), 1, fin ) != 1) + return UNZ_EOF; *pX = __LittleLong( v); return UNZ_OK; diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index b1e8391a..3d731333 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -297,9 +297,16 @@ int vfsLoadFile (const char *filename, void **bufferptr, int index) *bufferptr = safe_malloc (len+1); if (*bufferptr == NULL) - return -1; + { + fclose(f); + return -1; + } - fread (*bufferptr, 1, len, f); + if(fread (*bufferptr, 1, len, f) != len) + { + fclose(f); + return -1; + } fclose (f); // we need to end the buffer with a 0 diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index e72c012a..ca4f5fa6 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -291,7 +291,7 @@ deletes all empty or bad surfaces from the surface list 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 6332113d..b9291922 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); @@ -1025,7 +1028,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);