aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-11-10 23:55:22 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-11-10 23:55:22 +0000
commit8ba546241137c6c1c43751b25e40bbaf610658a1 (patch)
treea677c3ad74326acc217842a2d927328597cfe3c8 /code
parentb1613ef65246cc89a1e40e35c6e07080c56ea00b (diff)
downloadioquake3-aero-8ba546241137c6c1c43751b25e40bbaf610658a1.tar.gz
ioquake3-aero-8ba546241137c6c1c43751b25e40bbaf610658a1.zip
* Fix some new GCC 4.3 warnings
* Fix many many strict aliasing warnings, now that it's re-enabled git-svn-id: svn://svn.icculus.org/quake3/trunk@1487 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/client/cl_cin.c77
-rw-r--r--code/qcommon/cm_load.c19
-rw-r--r--code/qcommon/cmd.c15
-rw-r--r--code/qcommon/net_ip.c8
-rw-r--r--code/qcommon/q_shared.c3
-rw-r--r--code/qcommon/unzip.c6
-rw-r--r--code/qcommon/vm.c72
-rw-r--r--code/renderer/tr_bsp.c13
-rw-r--r--code/renderer/tr_image.c14
-rw-r--r--code/renderer/tr_image_bmp.c19
-rw-r--r--code/renderer/tr_image_jpg.c13
-rw-r--r--code/renderer/tr_image_pcx.c27
-rw-r--r--code/renderer/tr_image_png.c7
-rw-r--r--code/renderer/tr_image_tga.c15
-rw-r--r--code/renderer/tr_model.c27
-rw-r--r--code/sys/con_tty.c20
-rw-r--r--code/sys/sys_unix.c5
-rw-r--r--code/tools/lcc/src/bytecode.c3
-rw-r--r--code/ui/ui_shared.c9
19 files changed, 220 insertions, 152 deletions
diff --git a/code/client/cl_cin.c b/code/client/cl_cin.c
index 2e5a9b7..1fc5520 100644
--- a/code/client/cl_cin.c
+++ b/code/client/cl_cin.c
@@ -620,7 +620,10 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
unsigned short *aptr, *bptr, *cptr, *dptr;
long y0,y1,y2,y3,cr,cb;
byte *bbptr, *baptr, *bcptr, *bdptr;
- unsigned int *iaptr, *ibptr, *icptr, *idptr;
+ union {
+ unsigned int *i;
+ unsigned short *s;
+ } iaptr, ibptr, icptr, idptr;
if (!roq_flags) {
two = four = 256;
@@ -663,7 +666,7 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
VQ2TO4(aptr,bptr,cptr,dptr);
}
} else if (cinTable[currentHandle].samplesPerPixel==4) {
- ibptr = (unsigned int *)bptr;
+ ibptr.s = bptr;
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
@@ -671,20 +674,22 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
y3 = (long)*input++;
cr = (long)*input++;
cb = (long)*input++;
- *ibptr++ = yuv_to_rgb24( y0, cr, cb );
- *ibptr++ = yuv_to_rgb24( y1, cr, cb );
- *ibptr++ = yuv_to_rgb24( y2, cr, cb );
- *ibptr++ = yuv_to_rgb24( y3, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y0, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y1, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y2, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y3, cr, cb );
}
- icptr = (unsigned int *)vq4;
- idptr = (unsigned int *)vq8;
+ icptr.s = vq4;
+ idptr.s = vq8;
for(i=0;i<four;i++) {
- iaptr = (unsigned int *)vq2 + (*input++)*4;
- ibptr = (unsigned int *)vq2 + (*input++)*4;
+ iaptr.s = vq2;
+ iaptr.i += (*input++)*4;
+ ibptr.s = vq2;
+ ibptr.i += (*input++)*4;
for(j=0;j<2;j++)
- VQ2TO4(iaptr, ibptr, icptr, idptr);
+ VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i);
}
} else if (cinTable[currentHandle].samplesPerPixel==1) {
bbptr = (byte *)bptr;
@@ -739,7 +744,7 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
}
}
} else if (cinTable[currentHandle].samplesPerPixel==4) {
- ibptr = (unsigned int *)bptr;
+ ibptr.s = bptr;
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
@@ -747,25 +752,27 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
y3 = (long)*input++;
cr = (long)*input++;
cb = (long)*input++;
- *ibptr++ = yuv_to_rgb24( y0, cr, cb );
- *ibptr++ = yuv_to_rgb24( y1, cr, cb );
- *ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb );
- *ibptr++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb );
- *ibptr++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb );
- *ibptr++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb );
- *ibptr++ = yuv_to_rgb24( y2, cr, cb );
- *ibptr++ = yuv_to_rgb24( y3, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y0, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y1, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y2, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y3, cr, cb );
}
- icptr = (unsigned int *)vq4;
- idptr = (unsigned int *)vq8;
+ icptr.s = vq4;
+ idptr.s = vq8;
for(i=0;i<four;i++) {
- iaptr = (unsigned int *)vq2 + (*input++)*8;
- ibptr = (unsigned int *)vq2 + (*input++)*8;
+ iaptr.s = vq2;
+ iaptr.i += (*input++)*8;
+ ibptr.s = vq2;
+ ibptr.i += (*input++)*8;
for(j=0;j<2;j++) {
- VQ2TO4(iaptr, ibptr, icptr, idptr);
- VQ2TO4(iaptr, ibptr, icptr, idptr);
+ VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i);
+ VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i);
}
}
} else if (cinTable[currentHandle].samplesPerPixel==1) {
@@ -841,24 +848,26 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
}
}
} else if (cinTable[currentHandle].samplesPerPixel == 4) {
- ibptr = (unsigned int *) bptr;
+ ibptr.s = bptr;
for(i=0;i<two;i++) {
y0 = (long)*input; input+=2;
y2 = (long)*input; input+=2;
cr = (long)*input++;
cb = (long)*input++;
- *ibptr++ = yuv_to_rgb24( y0, cr, cb );
- *ibptr++ = yuv_to_rgb24( y2, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y0, cr, cb );
+ *ibptr.i++ = yuv_to_rgb24( y2, cr, cb );
}
- icptr = (unsigned int *)vq4;
- idptr = (unsigned int *)vq8;
+ icptr.s = vq4;
+ idptr.s = vq8;
for(i=0;i<four;i++) {
- iaptr = (unsigned int *)vq2 + (*input++)*2;
- ibptr = (unsigned int *)vq2 + (*input++)*2;
+ iaptr.s = vq2;
+ iaptr.i += (*input++)*2;
+ ibptr.s = vq2 + (*input++)*2;
+ ibptr.i += (*input++)*2;
for(j=0;j<2;j++) {
- VQ2TO2(iaptr,ibptr,icptr,idptr);
+ VQ2TO2(iaptr.i,ibptr.i,icptr.i,idptr.i);
}
}
}
diff --git a/code/qcommon/cm_load.c b/code/qcommon/cm_load.c
index 175f138..a06358b 100644
--- a/code/qcommon/cm_load.c
+++ b/code/qcommon/cm_load.c
@@ -567,7 +567,10 @@ Loads in the map and all submodels
==================
*/
void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
- int *buf;
+ union {
+ int *i;
+ void *v;
+ } buf;
int i;
dheader_t header;
int length;
@@ -606,19 +609,19 @@ void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
// load the file
//
#ifndef BSPC
- length = FS_ReadFile( name, (void **)&buf );
+ length = FS_ReadFile( name, &buf.v );
#else
- length = LoadQuakeFile((quakefile_t *) name, (void **)&buf);
+ length = LoadQuakeFile((quakefile_t *) name, &buf.v);
#endif
- if ( !buf ) {
+ if ( !buf.i ) {
Com_Error (ERR_DROP, "Couldn't load %s", name);
}
- last_checksum = LittleLong (Com_BlockChecksum (buf, length));
+ last_checksum = LittleLong (Com_BlockChecksum (buf.i, length));
*checksum = last_checksum;
- header = *(dheader_t *)buf;
+ header = *(dheader_t *)buf.i;
for (i=0 ; i<sizeof(dheader_t)/4 ; i++) {
((int *)&header)[i] = LittleLong ( ((int *)&header)[i]);
}
@@ -628,7 +631,7 @@ void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
, name, header.version, BSP_VERSION );
}
- cmod_base = (byte *)buf;
+ cmod_base = (byte *)buf.i;
// load into heap
CMod_LoadShaders( &header.lumps[LUMP_SHADERS] );
@@ -645,7 +648,7 @@ void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
CMod_LoadPatches( &header.lumps[LUMP_SURFACES], &header.lumps[LUMP_DRAWVERTS] );
// we are NOT freeing the file, because it is cached for the ref
- FS_FreeFile (buf);
+ FS_FreeFile (buf.v);
CM_InitBoxHull ();
diff --git a/code/qcommon/cmd.c b/code/qcommon/cmd.c
index 1f05452..08af301 100644
--- a/code/qcommon/cmd.c
+++ b/code/qcommon/cmd.c
@@ -239,7 +239,10 @@ Cmd_Exec_f
===============
*/
void Cmd_Exec_f( void ) {
- char *f;
+ union {
+ char *c;
+ void *v;
+ } f;
int len;
char filename[MAX_QPATH];
@@ -249,17 +252,17 @@ void Cmd_Exec_f( void ) {
}
Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
- COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
- len = FS_ReadFile( filename, (void **)&f);
- if (!f) {
+ COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
+ len = FS_ReadFile( filename, &f.v);
+ if (!f.c) {
Com_Printf ("couldn't exec %s\n",Cmd_Argv(1));
return;
}
Com_Printf ("execing %s\n",Cmd_Argv(1));
- Cbuf_InsertText (f);
+ Cbuf_InsertText (f.c);
- FS_FreeFile (f);
+ FS_FreeFile (f.v);
}
diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c
index 05a17a4..8ac39a5 100644
--- a/code/qcommon/net_ip.c
+++ b/code/qcommon/net_ip.c
@@ -786,7 +786,7 @@ NET_IPSocket
int NET_IPSocket( char *net_interface, int port, int *err ) {
SOCKET newsocket;
struct sockaddr_in address;
- qboolean _true = qtrue;
+ u_long _true = 1;
int i = 1;
*err = 0;
@@ -804,7 +804,7 @@ int NET_IPSocket( char *net_interface, int port, int *err ) {
return newsocket;
}
// make it non-blocking
- if( ioctlsocket( newsocket, FIONBIO, (u_long *)&_true ) == SOCKET_ERROR ) {
+ if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
Com_Printf( "WARNING: NET_IPSocket: ioctl FIONBIO: %s\n", NET_ErrorString() );
*err = socketError;
closesocket(newsocket);
@@ -857,7 +857,7 @@ NET_IP6Socket
int NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, int *err ) {
SOCKET newsocket;
struct sockaddr_in6 address;
- qboolean _true = qtrue;
+ u_long _true = 1;
*err = 0;
@@ -879,7 +879,7 @@ int NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, i
}
// make it non-blocking
- if( ioctlsocket( newsocket, FIONBIO, (u_long *)&_true ) == SOCKET_ERROR ) {
+ if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
Com_Printf( "WARNING: NET_IP6Socket: ioctl FIONBIO: %s\n", NET_ErrorString() );
*err = socketError;
closesocket(newsocket);
diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c
index 1ddab8d..550d100 100644
--- a/code/qcommon/q_shared.c
+++ b/code/qcommon/q_shared.c
@@ -710,11 +710,12 @@ qboolean Q_isanumber( const char *s )
return qfalse;
#else
char *p;
+ double d;
if( *s == '\0' )
return qfalse;
- strtod( s, &p );
+ d = strtod( s, &p );
return *p == '\0';
#endif
diff --git a/code/qcommon/unzip.c b/code/qcommon/unzip.c
index 90f5354..7669aa9 100644
--- a/code/qcommon/unzip.c
+++ b/code/qcommon/unzip.c
@@ -1109,7 +1109,8 @@ static int unzlocal_getShort (FILE* fin, uLong *pX)
{
short v;
- fread( &v, sizeof(v), 1, fin );
+ size_t size;
+ size = fread( &v, sizeof(v), 1, fin );
*pX = LittleShort( v);
return UNZ_OK;
@@ -1138,7 +1139,8 @@ static int unzlocal_getLong (FILE *fin, uLong *pX)
{
int v;
- fread( &v, sizeof(v), 1, fin );
+ size_t size;
+ size = fread( &v, sizeof(v), 1, fin );
*pX = LittleLong( v);
return UNZ_OK;
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index c2efcd2..dceec4a 100644
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -218,7 +218,11 @@ VM_LoadSymbols
*/
void VM_LoadSymbols( vm_t *vm ) {
int len;
- char *mapfile, *text_p, *token;
+ union {
+ char *c;
+ void *v;
+ } mapfile;
+ char *text_p, *token;
char name[MAX_QPATH];
char symbols[MAX_QPATH];
vmSymbol_t **prev, *sym;
@@ -235,8 +239,8 @@ void VM_LoadSymbols( vm_t *vm ) {
COM_StripExtension(vm->name, name, sizeof(name));
Com_sprintf( symbols, sizeof( symbols ), "vm/%s.map", name );
- len = FS_ReadFile( symbols, (void **)&mapfile );
- if ( !mapfile ) {
+ len = FS_ReadFile( symbols, &mapfile.v );
+ if ( !mapfile.c ) {
Com_Printf( "Couldn't load symbol file: %s\n", symbols );
return;
}
@@ -244,7 +248,7 @@ void VM_LoadSymbols( vm_t *vm ) {
numInstructions = vm->instructionPointersLength >> 2;
// parse the symbols
- text_p = mapfile;
+ text_p = mapfile.c;
prev = &vm->symbols;
count = 0;
@@ -291,7 +295,7 @@ void VM_LoadSymbols( vm_t *vm ) {
vm->numSymbols = count;
Com_Printf( "%i symbols parsed from %s\n", count, symbols );
- FS_FreeFile( mapfile );
+ FS_FreeFile( mapfile.v );
}
/*
@@ -364,47 +368,50 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
int dataLength;
int i;
char filename[MAX_QPATH];
- vmHeader_t *header;
+ union {
+ vmHeader_t *h;
+ void *v;
+ } header;
// load the image
Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", vm->name );
Com_Printf( "Loading vm file %s...\n", filename );
- length = FS_ReadFile( filename, (void **)&header );
- if ( !header ) {
+ length = FS_ReadFile( filename, &header.v );
+ if ( !header.h ) {
Com_Printf( "Failed.\n" );
VM_Free( vm );
return NULL;
}
- if( LittleLong( header->vmMagic ) == VM_MAGIC_VER2 ) {
+ if( LittleLong( header.h->vmMagic ) == VM_MAGIC_VER2 ) {
Com_Printf( "...which has vmMagic VM_MAGIC_VER2\n" );
// byte swap the header
for ( i = 0 ; i < sizeof( vmHeader_t ) / 4 ; i++ ) {
- ((int *)header)[i] = LittleLong( ((int *)header)[i] );
+ ((int *)header.h)[i] = LittleLong( ((int *)header.h)[i] );
}
// validate
- if ( header->jtrgLength < 0
- || header->bssLength < 0
- || header->dataLength < 0
- || header->litLength < 0
- || header->codeLength <= 0 ) {
+ if ( header.h->jtrgLength < 0
+ || header.h->bssLength < 0
+ || header.h->dataLength < 0
+ || header.h->litLength < 0
+ || header.h->codeLength <= 0 ) {
VM_Free( vm );
Com_Error( ERR_FATAL, "%s has bad header", filename );
}
- } else if( LittleLong( header->vmMagic ) == VM_MAGIC ) {
+ } else if( LittleLong( header.h->vmMagic ) == VM_MAGIC ) {
// byte swap the header
// sizeof( vmHeader_t ) - sizeof( int ) is the 1.32b vm header size
for ( i = 0 ; i < ( sizeof( vmHeader_t ) - sizeof( int ) ) / 4 ; i++ ) {
- ((int *)header)[i] = LittleLong( ((int *)header)[i] );
+ ((int *)header.h)[i] = LittleLong( ((int *)header.h)[i] );
}
// validate
- if ( header->bssLength < 0
- || header->dataLength < 0
- || header->litLength < 0
- || header->codeLength <= 0 ) {
+ if ( header.h->bssLength < 0
+ || header.h->dataLength < 0
+ || header.h->litLength < 0
+ || header.h->codeLength <= 0 ) {
VM_Free( vm );
Com_Error( ERR_FATAL, "%s has bad header", filename );
}
@@ -416,7 +423,7 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
// round up to next power of 2 so all data operations can
// be mask protected
- dataLength = header->dataLength + header->litLength + header->bssLength;
+ dataLength = header.h->dataLength + header.h->litLength + header.h->bssLength;
for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {
}
dataLength = 1 << i;
@@ -431,33 +438,34 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
}
// copy the intialized data
- Com_Memcpy( vm->dataBase, (byte *)header + header->dataOffset, header->dataLength + header->litLength );
+ Com_Memcpy( vm->dataBase, (byte *)header.h + header.h->dataOffset,
+ header.h->dataLength + header.h->litLength );
// byte swap the longs
- for ( i = 0 ; i < header->dataLength ; i += 4 ) {
+ for ( i = 0 ; i < header.h->dataLength ; i += 4 ) {
*(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) );
}
- if( header->vmMagic == VM_MAGIC_VER2 ) {
- vm->numJumpTableTargets = header->jtrgLength >> 2;
+ if( header.h->vmMagic == VM_MAGIC_VER2 ) {
+ vm->numJumpTableTargets = header.h->jtrgLength >> 2;
Com_Printf( "Loading %d jump table targets\n", vm->numJumpTableTargets );
if( alloc ) {
- vm->jumpTableTargets = Hunk_Alloc( header->jtrgLength, h_high );
+ vm->jumpTableTargets = Hunk_Alloc( header.h->jtrgLength, h_high );
} else {
- Com_Memset( vm->jumpTableTargets, 0, header->jtrgLength );
+ Com_Memset( vm->jumpTableTargets, 0, header.h->jtrgLength );
}
- Com_Memcpy( vm->jumpTableTargets, (byte *)header + header->dataOffset +
- header->dataLength + header->litLength, header->jtrgLength );
+ Com_Memcpy( vm->jumpTableTargets, (byte *)header.h + header.h->dataOffset +
+ header.h->dataLength + header.h->litLength, header.h->jtrgLength );
// byte swap the longs
- for ( i = 0 ; i < header->jtrgLength ; i += 4 ) {
+ for ( i = 0 ; i < header.h->jtrgLength ; i += 4 ) {
*(int *)(vm->jumpTableTargets + i) = LittleLong( *(int *)(vm->jumpTableTargets + i ) );
}
}
- return header;
+ return header.h;
}
/*
diff --git a/code/renderer/tr_bsp.c b/code/renderer/tr_bsp.c
index 90aaf9d..8e0031b 100644
--- a/code/renderer/tr_bsp.c
+++ b/code/renderer/tr_bsp.c
@@ -1795,7 +1795,10 @@ Called directly from cgame
void RE_LoadWorldMap( const char *name ) {
int i;
dheader_t *header;
- byte *buffer;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
byte *startMarker;
if ( tr.worldMapLoaded ) {
@@ -1813,8 +1816,8 @@ void RE_LoadWorldMap( const char *name ) {
tr.worldMapLoaded = qtrue;
// load it
- ri.FS_ReadFile( name, (void **)&buffer );
- if ( !buffer ) {
+ ri.FS_ReadFile( name, &buffer.v );
+ if ( !buffer.b ) {
ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name);
}
@@ -1831,7 +1834,7 @@ void RE_LoadWorldMap( const char *name ) {
startMarker = ri.Hunk_Alloc(0, h_low);
c_gridVerts = 0;
- header = (dheader_t *)buffer;
+ header = (dheader_t *)buffer.b;
fileBase = (byte *)header;
i = LittleLong (header->version);
@@ -1863,6 +1866,6 @@ void RE_LoadWorldMap( const char *name ) {
// only set tr.world now that we know the entire level has loaded properly
tr.world = &s_worldData;
- ri.FS_FreeFile( buffer );
+ ri.FS_FreeFile( buffer.v );
}
diff --git a/code/renderer/tr_image.c b/code/renderer/tr_image.c
index 2c3b72f..c86e32a 100644
--- a/code/renderer/tr_image.c
+++ b/code/renderer/tr_image.c
@@ -1431,7 +1431,11 @@ qhandle_t RE_RegisterSkin( const char *name ) {
qhandle_t hSkin;
skin_t *skin;
skinSurface_t *surf;
- char *text, *text_p;
+ union {
+ char *c;
+ void *v;
+ } text;
+ char *text_p;
char *token;
char surfName[MAX_QPATH];
@@ -1480,12 +1484,12 @@ qhandle_t RE_RegisterSkin( const char *name ) {
}
// load and parse the skin file
- ri.FS_ReadFile( name, (void **)&text );
- if ( !text ) {
+ ri.FS_ReadFile( name, &text.v );
+ if ( !text.c ) {
return 0;
}
- text_p = text;
+ text_p = text.c;
while ( text_p && *text_p ) {
// get surface name
token = CommaParse( &text_p );
@@ -1514,7 +1518,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
skin->numSurfaces++;
}
- ri.FS_FreeFile( text );
+ ri.FS_FreeFile( text.v );
// never let a skin have 0 shaders
diff --git a/code/renderer/tr_image_bmp.c b/code/renderer/tr_image_bmp.c
index 190b878..0b78abb 100644
--- a/code/renderer/tr_image_bmp.c
+++ b/code/renderer/tr_image_bmp.c
@@ -50,7 +50,10 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
int row, column;
byte *buf_p;
byte *end;
- byte *buffer = NULL;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
int length;
BMPHeader_t bmpHeader;
byte *bmpRGBA;
@@ -66,8 +69,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
//
// load the file
//
- length = ri.FS_ReadFile( ( char * ) name, (void **)&buffer);
- if (!buffer || length < 0) {
+ length = ri.FS_ReadFile( ( char * ) name, &buffer.v);
+ if (!buffer.b || length < 0) {
return;
}
@@ -76,8 +79,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
ri.Error( ERR_DROP, "LoadBMP: header too short (%s)\n", name );
}
- buf_p = buffer;
- end = buffer + length;
+ buf_p = buffer.b;
+ end = buffer.b + length;
bmpHeader.id[0] = *buf_p++;
bmpHeader.id[1] = *buf_p++;
@@ -119,12 +122,12 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
buf_p += sizeof(bmpHeader.palette);
}
- if (buffer + bmpHeader.bitmapDataOffset > end)
+ if (buffer.b + bmpHeader.bitmapDataOffset > end)
{
ri.Error( ERR_DROP, "LoadBMP: invalid offset value in header (%s)\n", name );
}
- buf_p = buffer + bmpHeader.bitmapDataOffset;
+ buf_p = buffer.b + bmpHeader.bitmapDataOffset;
if ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' )
{
@@ -231,6 +234,6 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
}
}
- ri.FS_FreeFile( buffer );
+ ri.FS_FreeFile( buffer.v );
}
diff --git a/code/renderer/tr_image_jpg.c b/code/renderer/tr_image_jpg.c
index fb4f212..2e1a52a 100644
--- a/code/renderer/tr_image_jpg.c
+++ b/code/renderer/tr_image_jpg.c
@@ -57,7 +57,10 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
unsigned pixelcount, memcount;
unsigned char *out;
int len;
- byte *fbuffer;
+ union {
+ byte *b;
+ void *v;
+ } fbuffer;
byte *buf;
/* In this example we want to open the input file before doing anything else,
@@ -66,8 +69,8 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
* requires it in order to read binary files.
*/
- len = ri.FS_ReadFile ( ( char * ) filename, (void **)&fbuffer);
- if (!fbuffer || len < 0) {
+ len = ri.FS_ReadFile ( ( char * ) filename, &fbuffer.v);
+ if (!fbuffer.b || len < 0) {
return;
}
@@ -85,7 +88,7 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
/* Step 2: specify data source (eg, a file) */
- jpeg_mem_src(&cinfo, fbuffer, len);
+ jpeg_mem_src(&cinfo, fbuffer.b, len);
/* Step 3: read file parameters with jpeg_read_header() */
@@ -203,7 +206,7 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
* so as to simplify the setjmp error logic above. (Actually, I don't
* think that jpeg_destroy can do an error exit, but why assume anything...)
*/
- ri.FS_FreeFile (fbuffer);
+ ri.FS_FreeFile (fbuffer.v);
/* At this point you may want to check to see whether any corrupt-data
* warnings occurred (test whether jerr.pub.num_warnings is nonzero).
diff --git a/code/renderer/tr_image_pcx.c b/code/renderer/tr_image_pcx.c
index db407de..d1b1a5e 100644
--- a/code/renderer/tr_image_pcx.c
+++ b/code/renderer/tr_image_pcx.c
@@ -50,7 +50,10 @@ typedef struct {
void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
{
- byte *raw;
+ union {
+ byte *b;
+ void *v;
+ } raw;
byte *end;
pcx_t *pcx;
int len;
@@ -71,23 +74,23 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
//
// load the file
//
- len = ri.FS_ReadFile( ( char * ) filename, (void **)&raw);
- if (!raw || len < 0) {
+ len = ri.FS_ReadFile( ( char * ) filename, &raw.v);
+ if (!raw.b || len < 0) {
return;
}
if((unsigned)len < sizeof(pcx_t))
{
ri.Printf (PRINT_ALL, "PCX truncated: %s\n", filename);
- ri.FS_FreeFile (raw);
+ ri.FS_FreeFile (raw.v);
return;
}
//
// parse the PCX file
//
- pcx = (pcx_t *)raw;
- end = raw+len;
+ pcx = (pcx_t *)raw.b;
+ end = raw.b+len;
w = LittleShort(pcx->xmax)+1;
h = LittleShort(pcx->ymax)+1;
@@ -107,7 +110,7 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
pix = pic8 = ri.Malloc ( size );
- raw = pcx->data;
+ raw.b = pcx->data;
// FIXME: should use bytes_per_line but original q3 didn't do that either
while(pix < pic8+size)
{
@@ -117,16 +120,16 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
continue;
}
- if(raw+1 > end)
+ if(raw.b+1 > end)
break;
- dataByte = *raw++;
+ dataByte = *raw.b++;
if((dataByte & 0xC0) == 0xC0)
{
- if(raw+1 > end)
+ if(raw.b+1 > end)
break;
runLength = dataByte & 0x3F;
- dataByte = *raw++;
+ dataByte = *raw.b++;
}
else
runLength = 1;
@@ -139,7 +142,7 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
ri.Free (pic8);
}
- if (raw-(byte*)pcx >= end - (byte*)769 || end[-769] != 0x0c)
+ if (raw.b-(byte*)pcx >= end - (byte*)769 || end[-769] != 0x0c)
{
ri.Printf (PRINT_ALL, "PCX missing palette: %s\n", filename);
ri.FS_FreeFile (pcx);
diff --git a/code/renderer/tr_image_png.c b/code/renderer/tr_image_png.c
index e33ffff..ef44c16 100644
--- a/code/renderer/tr_image_png.c
+++ b/code/renderer/tr_image_png.c
@@ -215,6 +215,10 @@ struct BufferedFile
static struct BufferedFile *ReadBufferedFile(const char *name)
{
struct BufferedFile *BF;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
/*
* input verification
@@ -248,7 +252,8 @@ static struct BufferedFile *ReadBufferedFile(const char *name)
* Read the file.
*/
- BF->Length = ri.FS_ReadFile((char *) name, (void **) &BF->Buffer);
+ BF->Length = ri.FS_ReadFile((char *) name, &buffer.v);
+ BF->Buffer = buffer.b;
/*
* Did we get it? Is it big enough?
diff --git a/code/renderer/tr_image_tga.c b/code/renderer/tr_image_tga.c
index 2147acd..e66e60d 100644
--- a/code/renderer/tr_image_tga.c
+++ b/code/renderer/tr_image_tga.c
@@ -45,7 +45,10 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
int row, column;
byte *buf_p;
byte *end;
- byte *buffer = NULL;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
TargaHeader targa_header;
byte *targa_rgba;
int length;
@@ -60,8 +63,8 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
//
// load the file
//
- length = ri.FS_ReadFile ( ( char * ) name, (void **)&buffer);
- if (!buffer || length < 0) {
+ length = ri.FS_ReadFile ( ( char * ) name, &buffer.v);
+ if (!buffer.b || length < 0) {
return;
}
@@ -70,8 +73,8 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
ri.Error( ERR_DROP, "LoadTGA: header too short (%s)\n", name );
}
- buf_p = buffer;
- end = buffer + length;
+ buf_p = buffer.b;
+ end = buffer.b + length;
targa_header.id_length = buf_p[0];
targa_header.colormap_type = buf_p[1];
@@ -313,5 +316,5 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
*pic = targa_rgba;
- ri.FS_FreeFile (buffer);
+ ri.FS_FreeFile (buffer.v);
}
diff --git a/code/renderer/tr_model.c b/code/renderer/tr_model.c
index d721e2f..5355580 100644
--- a/code/renderer/tr_model.c
+++ b/code/renderer/tr_model.c
@@ -83,7 +83,10 @@ asked for again.
*/
qhandle_t RE_RegisterModel( const char *name ) {
model_t *mod;
- unsigned *buf;
+ union {
+ unsigned *u;
+ void *v;
+ } buf;
int lod;
int ident;
qboolean loaded = qfalse;
@@ -151,19 +154,19 @@ qhandle_t RE_RegisterModel( const char *name ) {
{
int filesize;
- filesize = ri.FS_ReadFile(name, (void **) &buf);
- if(!buf)
+ filesize = ri.FS_ReadFile(name, (void **) &buf.v);
+ if(!buf.u)
{
ri.Printf (PRINT_WARNING,"RE_RegisterModel: couldn't load %s\n", name);
mod->type = MOD_BAD;
return 0;
}
- ident = LittleLong(*(unsigned *)buf);
+ ident = LittleLong(*(unsigned *)buf.u);
if(ident == MDR_IDENT)
- loaded = R_LoadMDR(mod, buf, filesize, name);
+ loaded = R_LoadMDR(mod, buf.u, filesize, name);
- ri.FS_FreeFile (buf);
+ ri.FS_FreeFile (buf.v);
if(!loaded)
{
@@ -184,26 +187,26 @@ qhandle_t RE_RegisterModel( const char *name ) {
else
Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext);
- ri.FS_ReadFile( namebuf, (void **)&buf );
- if ( !buf ) {
+ ri.FS_ReadFile( namebuf, &buf.v );
+ if ( !buf.u ) {
continue;
}
loadmodel = mod;
- ident = LittleLong(*(unsigned *)buf);
+ ident = LittleLong(*(unsigned *)buf.u);
if ( ident == MD4_IDENT ) {
- loaded = R_LoadMD4( mod, buf, name );
+ loaded = R_LoadMD4( mod, buf.u, name );
} else {
if ( ident != MD3_IDENT ) {
ri.Printf (PRINT_WARNING,"RE_RegisterModel: unknown fileid for %s\n", name);
goto fail;
}
- loaded = R_LoadMD3( mod, lod, buf, name );
+ loaded = R_LoadMD3( mod, lod, buf.u, name );
}
- ri.FS_FreeFile (buf);
+ ri.FS_FreeFile (buf.v);
if ( !loaded ) {
if ( lod == 0 ) {
diff --git a/code/sys/con_tty.c b/code/sys/con_tty.c
index c2e553a..28f1fd4 100644
--- a/code/sys/con_tty.c
+++ b/code/sys/con_tty.c
@@ -86,12 +86,14 @@ send "\b \b"
static void CON_Back( void )
{
char key;
+ size_t size;
+
key = '\b';
- write(1, &key, 1);
+ size = write(1, &key, 1);
key = ' ';
- write(1, &key, 1);
+ size = write(1, &key, 1);
key = '\b';
- write(1, &key, 1);
+ size = write(1, &key, 1);
}
/*
@@ -142,12 +144,13 @@ static void CON_Show( void )
ttycon_hide--;
if (ttycon_hide == 0)
{
- write( 1, "]", 1 );
+ size_t size;
+ size = write( 1, "]", 1 );
if (TTY_con.cursor)
{
for (i=0; i<TTY_con.cursor; i++)
{
- write(1, TTY_con.buffer+i, 1);
+ size = write(1, TTY_con.buffer+i, 1);
}
}
}
@@ -307,6 +310,7 @@ char *CON_Input( void )
int avail;
char key;
field_t *history;
+ size_t size;
if( ttycon_on )
{
@@ -336,8 +340,8 @@ char *CON_Input( void )
strcpy(text, TTY_con.buffer);
Field_Clear(&TTY_con);
key = '\n';
- write(1, &key, 1);
- write( 1, "]", 1 );
+ size = write(1, &key, 1);
+ size = write( 1, "]", 1 );
return text;
}
if (key == '\t')
@@ -399,7 +403,7 @@ char *CON_Input( void )
TTY_con.buffer[TTY_con.cursor] = key;
TTY_con.cursor++;
// print the current line (this is differential)
- write(1, &key, 1);
+ size = write(1, &key, 1);
}
return NULL;
diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c
index 21d0b57..c05fda5 100644
--- a/code/sys/sys_unix.c
+++ b/code/sys/sys_unix.c
@@ -231,7 +231,10 @@ char *Sys_Cwd( void )
{
static char cwd[MAX_OSPATH];
- getcwd( cwd, sizeof( cwd ) - 1 );
+ char *result = getcwd( cwd, sizeof( cwd ) - 1 );
+ if( result != cwd )
+ return NULL;
+
cwd[MAX_OSPATH-1] = 0;
return cwd;
diff --git a/code/tools/lcc/src/bytecode.c b/code/tools/lcc/src/bytecode.c
index 871056a..e83429f 100644
--- a/code/tools/lcc/src/bytecode.c
+++ b/code/tools/lcc/src/bytecode.c
@@ -261,7 +261,8 @@ static void LoadSourceFile( const char *filename ) {
length = filelength( f );
sourceFile = malloc( length + 1 );
if ( sourceFile ) {
- fread( sourceFile, length, 1, f );
+ size_t size;
+ size = fread( sourceFile, length, 1, f );
sourceFile[length] = 0;
}
diff --git a/code/ui/ui_shared.c b/code/ui/ui_shared.c
index 3b2ac7d..e6e460c 100644
--- a/code/ui/ui_shared.c
+++ b/code/ui/ui_shared.c
@@ -5239,9 +5239,16 @@ qboolean MenuParse_name( itemDef_t *item, int handle ) {
qboolean MenuParse_fullscreen( itemDef_t *item, int handle ) {
menuDef_t *menu = (menuDef_t*)item;
- if (!PC_Int_Parse(handle, (int*) &menu->fullScreen)) {
+ union
+ {
+ qboolean b;
+ int i;
+ } fullScreen;
+
+ if (!PC_Int_Parse(handle, &fullScreen.i)) {
return qfalse;
}
+ menu->fullScreen = fullScreen.b;
return qtrue;
}