]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
fix some more warnings
authorRudolf Polzer <divverent@alientrap.org>
Tue, 5 Oct 2010 13:04:45 +0000 (15:04 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 5 Oct 2010 13:04:45 +0000 (15:04 +0200)
libs/ddslib/ddslib.c
libs/picomodel/lwo/lwob.c
libs/picomodel/lwo/pntspols.c
tools/quake3/common/cmdlib.c
tools/quake3/common/polylib.c
tools/quake3/common/threads.c
tools/quake3/common/unzip.c
tools/quake3/common/vfs.c
tools/quake3/q3map2/surface.c
tools/quake3/q3map2/vis.c

index bf1a9f15e217593fff7fa365e73a43fb1747bf0c..424faeea156d20ba47edb6df623ff33f4e9e31e8 100644 (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++ )
index 2d0522d5f873edfe7e5802802a00d549c8db9186..f12e3a362b86a9fe4bd4bbdda60a2827bcd28ae0 100644 (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;
index a7f54d251f37ddfa40d9e7e99a9be16d5d301b1a..314758199c07d2ec1e88002996466d8975805ba4 100644 (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;
       }
index fac9bdbbd546d9d673f280d952802f48178423d3..5168d233f38846dc7014351cc8200f83ab496af1 100644 (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 )
index 21067ca2e49731f393f1aab87480a425c9d58cad..fc8805e72da1ebf02b94ec0e02ce36702189890a 100644 (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;
 }
index a486abafaea5006e169ece64f156579523260734..7f404a4f03da537b6b90f33c09647ca65139f2a3 100644 (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++)
index 41b09cb33b52a7b1c370fccf0f6af7a8982a3560..1e2be2be5f121af516f4fb92cce822761eb28ac9 100644 (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;
index b1e8391a7a7515204005b57c4c7f64f564cedc73..3d73133300678930c758468bf17dec7528e05359 100644 (file)
@@ -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
index e72c012a869b15d1737923d1b2a7d500972ec7bc..ca4f5fa6ebd28138f4978040c365524d4d7d292a 100644 (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 */
index 6332113d4abe418f57fe884fc3d870a0aa5f54fa..b92919226af604a9089019940bcb33f8410c3a5c 100644 (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);