fix some more warnings

This commit is contained in:
Rudolf Polzer 2010-10-05 15:04:45 +02:00
parent 4487b4d44f
commit d5a9782200
10 changed files with 32 additions and 17 deletions

View File

@ -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++ )

View File

@ -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;

View File

@ -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;
}

View File

@ -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 )

View File

@ -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;
}

View File

@ -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++)

View File

@ -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;

View File

@ -297,9 +297,16 @@ int vfsLoadFile (const char *filename, void **bufferptr, int index)
*bufferptr = safe_malloc (len+1);
if (*bufferptr == NULL)
{
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

View File

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

View File

@ -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);