]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
quake3 common: various warning fixes from NetRadiant
authorRudolf Polzer <divverent@alientrap.org>
Wed, 23 Feb 2011 09:48:56 +0000 (10:48 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Wed, 23 Feb 2011 09:52:11 +0000 (10:52 +0100)
tools/quake3/common/cmdlib.c
tools/quake3/common/cmdlib.h
tools/quake3/common/imagelib.c
tools/quake3/common/inout.c
tools/quake3/common/polylib.c
tools/quake3/common/unzip.c
tools/quake3/common/vfs.c

index 24c9811f638a44a434c30f332ce84954a3a2c31b..6e4a0520f6dc57c8f69c50ef068dc201d8199cb5 100644 (file)
@@ -193,7 +193,7 @@ void SetQdirFromPath( const char *path )
       }
                        strncpy (qdir, path, c+len+count-path);
                        Sys_Printf ("qdir: %s\n", qdir);
-                       for ( i = 0; i < strlen( qdir ); i++ )
+                       for ( i = 0; i < (int) strlen( qdir ); i++ )
                        {
                                if ( qdir[i] == '\\' ) 
                                        qdir[i] = '/';
@@ -206,7 +206,7 @@ void SetQdirFromPath( const char *path )
                                {
                                        strncpy (gamedir, path, c+1-path);
 
-                                       for ( i = 0; i < strlen( gamedir ); i++ )
+                                       for ( i = 0; i < (int) strlen( gamedir ); i++ )
                                        {
                                                if ( gamedir[i] == '\\' ) 
                                                        gamedir[i] = '/';
@@ -338,7 +338,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 7eee55eda6578fb38e23738a52e48e737cc87616..afb62d921b6cfb43ad91115b00db0a5d4a342fb5 100644 (file)
@@ -95,7 +95,11 @@ void ExpandWildcards( int *argc, char ***argv );
 
 double I_FloatTime( void );
 
-void   Error( const char *error, ... );
+void   Error( const char *error, ... )
+#ifdef __GNUC__
+__attribute__((noreturn))
+#endif
+;
 int            CheckParm( const char *check );
 
 FILE   *SafeOpenWrite( const char *filename );
index f575202355f10b0258a31a3ec9ffc0dd843a07bd..fa588321b2a6a89103e810e40752f80bf56414ee 100644 (file)
@@ -527,6 +527,7 @@ void LoadPCX( const char *filename, byte **pic, byte **palette, int *width, int
        for( y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1 )
        {
                /* do a scanline */
+               runLength = 0;
                for( x=0; x <= pcx->xmax; )
                {
                        /* RR2DO2 */
@@ -1133,7 +1134,7 @@ void LoadTGA (const char *name, byte **pixels, int *width, int *height)
        //
        // load the file
        //
-       nLen = vfsLoadFile ( ( char * ) name, (void **)&buffer, 0);
+       nLen = vfsLoadFile ( name, (void **)&buffer, 0);
        if (nLen == -1)
        {
                Error ("Couldn't read %s", name);
index 6f127e3e5f45cb0c1bfebf7f7de8193e40271b28..318a0d247ea46ba60556f2309fb144d9e4244710 100644 (file)
@@ -71,8 +71,8 @@ xmlNodePtr xml_NodeForVec( vec3_t v )
   char buf[1024];
   
   sprintf (buf, "%f %f %f", v[0], v[1], v[2]);
-  ret = xmlNewNode (NULL, "point");
-  xmlNodeSetContent (ret, buf);
+  ret = xmlNewNode (NULL, (xmlChar*)"point");
+  xmlNodeSetContent (ret, (xmlChar*)buf);
   return ret;
 }
 
@@ -96,7 +96,7 @@ void xml_SendNode (xmlNodePtr node)
     // l_net library defines an upper limit of MAX_NETMESSAGE
     // there are some size check errors, so we use MAX_NETMESSAGE-10 to be safe
     // if the size of the buffer exceeds MAX_NETMESSAGE-10 we'll send in several network messages
-    while (pos < xml_buf->use)
+    while (pos < (int)xml_buf->use)
     {
       // what size are we gonna send now?
       (xml_buf->use - pos < MAX_NETMESSAGE - 10) ? (size = xml_buf->use - pos) : (size = MAX_NETMESSAGE - 10);
@@ -152,15 +152,15 @@ void xml_Select (char *msg, int entitynum, int brushnum, qboolean bError)
 
   // now build a proper "select" XML node
   sprintf (buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg);
-  node = xmlNewNode (NULL, "select");
-  xmlNodeSetContent (node, buf);
+  node = xmlNewNode (NULL, (xmlChar*)"select");
+  xmlNodeSetContent (node, (xmlChar*)buf);
   level[0] = (int)'0' + (bError ? SYS_ERR : SYS_WRN)  ;
   level[1] = 0;
-  xmlSetProp (node, "level", (char *)&level);
+  xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level);
   // a 'select' information
   sprintf (buf, "%i %i", entitynum, brushnum);
-  select = xmlNewNode (NULL, "brush");
-  xmlNodeSetContent (select, buf);
+  select = xmlNewNode (NULL, (xmlChar*)"brush");
+  xmlNodeSetContent (select, (xmlChar*)buf);
   xmlAddChild (node, select);
   xml_SendNode (node);
 
@@ -178,15 +178,15 @@ void xml_Point (char *msg, vec3_t pt)
   char buf[1024];
   char level[2];
 
-  node = xmlNewNode (NULL, "pointmsg");
-  xmlNodeSetContent (node, msg);
+  node = xmlNewNode (NULL, (xmlChar*)"pointmsg");
+  xmlNodeSetContent (node, (xmlChar*)msg);
   level[0] = (int)'0' + SYS_ERR;
   level[1] = 0;
-  xmlSetProp (node, "level", (char *)&level);
+  xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level);
   // a 'point' node
   sprintf (buf, "%g %g %g", pt[0], pt[1], pt[2]);
-  point = xmlNewNode (NULL, "point");
-  xmlNodeSetContent (point, buf);
+  point = xmlNewNode (NULL, (xmlChar*)"point");
+  xmlNodeSetContent (point, (xmlChar*)buf);
   xmlAddChild (node, point);
   xml_SendNode (node);
 
@@ -203,11 +203,11 @@ void xml_Winding (char *msg, vec3_t p[], int numpoints, qboolean die)
   char level[2];
   int i;
 
-  node = xmlNewNode (NULL, "windingmsg");
-  xmlNodeSetContent (node, msg);
+  node = xmlNewNode (NULL, (xmlChar*)"windingmsg");
+  xmlNodeSetContent (node, (xmlChar*)msg);
   level[0] = (int)'0' + SYS_ERR;
   level[1] = 0;
-  xmlSetProp (node, "level", (char *)&level);
+  xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level);
   // a 'winding' node
   sprintf( buf, "%i ", numpoints);
   for(i = 0; i < numpoints; i++)
@@ -219,8 +219,8 @@ void xml_Winding (char *msg, vec3_t p[], int numpoints, qboolean die)
          strcat( buf, smlbuf);
   }
 
-  winding = xmlNewNode (NULL, "winding");
-  xmlNodeSetContent (winding, buf);
+  winding = xmlNewNode (NULL, (xmlChar*)"winding");
+  xmlNodeSetContent (winding, (xmlChar*)buf);
   xmlAddChild (node, winding);
   xml_SendNode (node);
 
@@ -242,7 +242,7 @@ void Broadcast_Setup( const char *dest )
   char sMsg[1024];
 
        Net_Setup();
-       Net_StringToAddress((char *)dest, &address);
+       Net_StringToAddress(dest, &address);
   brdcst_socket = Net_Connect(&address, 0);
   if (brdcst_socket)
   {
@@ -271,7 +271,7 @@ void FPrintf (int flag, char *buf)
   static qboolean bGotXML = qfalse;
   char level[2];
 
-  printf(buf);
+  printf("%s", buf);
 
   // the following part is XML stuff only.. but maybe we don't want that message to go down the XML pipe?
   if (flag == SYS_NOXML)
@@ -288,19 +288,19 @@ void FPrintf (int flag, char *buf)
   if (!bGotXML)
   {
     // initialize
-    doc = xmlNewDoc("1.0");
-    doc->children = xmlNewDocRawNode(doc, NULL, "q3map_feedback", NULL);
+    doc = xmlNewDoc((xmlChar*)"1.0");
+    doc->children = xmlNewDocRawNode(doc, NULL, (xmlChar*)"q3map_feedback", NULL);
     bGotXML = qtrue;
   }
-  node = xmlNewNode (NULL, "message");
+  node = xmlNewNode (NULL, (xmlChar*)"message");
   {
     gchar* utf8 = g_locale_to_utf8(buf, -1, NULL, NULL, NULL); 
-    xmlNodeSetContent(node, utf8);
+    xmlNodeSetContent(node, (xmlChar*)utf8);
     g_free(utf8);
   }
   level[0] = (int)'0' + flag;
   level[1] = 0;
-  xmlSetProp (node, "level", (char *)&level );
+  xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level );
   
   xml_SendNode (node);
 }
index 78444f94bf35a9652be21df45f73bf82b2d2ade1..200ff82b9679704d725dd2349ab170c4e91eecd5 100644 (file)
@@ -457,13 +457,13 @@ CopyWinding
 */
 winding_t      *CopyWinding (winding_t *w)
 {
-       int                     size;
+       size_t                  size;
        winding_t       *c;
 
        if (!w) Error("CopyWinding: winding is NULL");
 
        c = AllocWinding (w->numpoints);
-       size = (int)((size_t)((winding_t *)0)->p[w->numpoints]);
+       size = (size_t)((winding_t *)NULL)->p[w->numpoints];
        memcpy (c, w, size);
        return c;
 }
index 1949db22c6f3bf4d1ce58e0ca200bdf6c75bdc89..76cafc027ee4803128bd59a235e741c0a67261db 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;
@@ -1635,10 +1637,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
 
        /* we check the magic */
        if (err==UNZ_OK)
+       {
                if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
                        err=UNZ_ERRNO;
                else if (uMagic!=0x02014b50)
                        err=UNZ_BADZIPFILE;
+       }
 
        if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
                err=UNZ_ERRNO;
@@ -1715,10 +1719,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
                        uSizeRead = extraFieldBufferSize;
 
                if (lSeek!=0)
+               {
                        if (fseek(s->file,lSeek,SEEK_CUR)==0)
                                lSeek=0;
                        else
                                err=UNZ_ERRNO;
+               }
                if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
                        if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
                                err=UNZ_ERRNO;
@@ -1740,10 +1746,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
                        uSizeRead = commentBufferSize;
 
                if (lSeek!=0)
+               {
                        if (fseek(s->file,lSeek,SEEK_CUR)==0)
                                lSeek=0;
                        else
                                err=UNZ_ERRNO;
+               }
                if ((file_info.size_file_comment>0) && (commentBufferSize>0))
                        if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
                                err=UNZ_ERRNO;
@@ -1906,10 +1914,12 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
 
 
        if (err==UNZ_OK)
+       {
                if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
                        err=UNZ_ERRNO;
                else if (uMagic!=0x04034b50)
                        err=UNZ_BADZIPFILE;
+       }
 
        if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
                err=UNZ_ERRNO;
@@ -3407,7 +3417,7 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inf
 
         /* compute minimum size table less than or equal to l bits */
         z = g - w;
-        z = z > (uInt)l ? l : z;        /* table size upper limit */
+        z = z > (uInt)l ? (uInt)l : z;        /* table size upper limit */
         if ((f = 1 << (j = k - w)) > a + 1)     /* try a k-w bit table */
         {                       /* too few codes for k-w bit table */
           f -= a + 1;           /* deduct codes from patterns left */
@@ -3445,7 +3455,10 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inf
       /* set up table entry in r */
       r.bits = (Byte)(k - w);
       if (p >= v + n)
+      {
         r.exop = 128 + 64;      /* out of values--invalid code */
+        r.base = 0;
+      }
       else if (*p < s)
       {
         r.exop = (Byte)(*p < 256 ? 0 : 32 + 64);     /* 256 is end-of-block */
index 258656612827fb9ae69dd23966b66ce1aedb1f57..4ca2457225bb54b9c75f300b43ce8719cf0b6428 100644 (file)
@@ -280,9 +280,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) != (size_t) len)
+       {
+               fclose(f);
+               return -1;
+       }
     fclose (f);
     
     // we need to end the buffer with a 0
@@ -317,9 +324,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) != (size_t) len)
+               {
+                 fclose(f);
+          return -1;
+               }
         fclose (f);
         
         // we need to end the buffer with a 0