]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3data/md3lib.c
gcc: appease the hardening warnings
[xonotic/netradiant.git] / tools / quake3 / q3data / md3lib.c
index 66dfa52d8283682dcb46b8706aa1100ea25526e3..ead6df21397feb4d10ad69f9773a2e2a16a57ba2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+   Copyright (C) 1999-2007 id Software, Inc. and contributors.
    For a list of contributors, see the accompanying CONTRIBUTORS file.
 
    This file is part of GtkRadiant.
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "globaldefs.h"
 #include <assert.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <io.h>
 #endif
 #include "md3lib.h"
 
-#if defined ( __linux__ ) || defined ( __APPLE__ )
-#define filelength Q_filelength
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#define filelength(f) Q_filelength(f)
+#else
+#define filelength(f) filelength(fileno(f))
 #endif
 
 /*
 ** MD3_ComputeTagFromTri
 */
-void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
+void MD3_ComputeTagFromTri( md3Tag_t *pTag, float pTri[3][3] ){
        float len[3];
        vec3_t axes[3], sides[3];
        int longestSide, shortestSide, hypotSide;
@@ -82,6 +85,9 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
                hypotSide = 2;
                origin = 1;
        }
+       else {
+               assert(0);
+       }
        len[hypotSide] = -1;
 
        if ( len[0] > len[1] && len[0] > len[2] ) {
@@ -93,6 +99,9 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
        else if ( len[2] > len[0] && len[2] > len[1] ) {
                longestSide = 2;
        }
+       else {
+               assert(0);
+       }
        len[longestSide] = -1;
 
        if ( len[0] > len[1] && len[0] > len[2] ) {
@@ -104,6 +113,9 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
        else if ( len[2] > len[0] && len[2] > len[1] ) {
                shortestSide = 2;
        }
+       else {
+               assert(0);
+       }
        len[shortestSide] = -1;
 
 
@@ -149,9 +161,9 @@ void MD3_Dump( const char *filename ){
                Error( "Unable to open '%s'\n", filename );
        }
 
-       fileSize = filelength( fileno( fp ) );
-       _buffer = malloc( filelength( fileno( fp ) ) );
-       fread( _buffer, fileSize, 1, fp );
+       fileSize = filelength( fp );
+       _buffer = malloc( fileSize );
+       assert(fread( _buffer, fileSize, 1, fp ));
        fclose( fp );
 
        buffer = ( char * ) _buffer;