r1487 - in trunk/code: client qcommon renderer sys tools/lcc/src ui
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Nov 10 18:55:22 EST 2008
Author: tma
Date: 2008-11-10 18:55:22 -0500 (Mon, 10 Nov 2008)
New Revision: 1487
Modified:
trunk/code/client/cl_cin.c
trunk/code/qcommon/cm_load.c
trunk/code/qcommon/cmd.c
trunk/code/qcommon/net_ip.c
trunk/code/qcommon/q_shared.c
trunk/code/qcommon/unzip.c
trunk/code/qcommon/vm.c
trunk/code/renderer/tr_bsp.c
trunk/code/renderer/tr_image.c
trunk/code/renderer/tr_image_bmp.c
trunk/code/renderer/tr_image_jpg.c
trunk/code/renderer/tr_image_pcx.c
trunk/code/renderer/tr_image_png.c
trunk/code/renderer/tr_image_tga.c
trunk/code/renderer/tr_model.c
trunk/code/sys/con_tty.c
trunk/code/sys/sys_unix.c
trunk/code/tools/lcc/src/bytecode.c
trunk/code/ui/ui_shared.c
Log:
* Fix some new GCC 4.3 warnings
* Fix many many strict aliasing warnings, now that it's re-enabled
Modified: trunk/code/client/cl_cin.c
===================================================================
--- trunk/code/client/cl_cin.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/client/cl_cin.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -620,7 +620,10 @@
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 @@
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 @@
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 @@
}
}
} 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 @@
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 @@
}
}
} 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);
}
}
}
Modified: trunk/code/qcommon/cm_load.c
===================================================================
--- trunk/code/qcommon/cm_load.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/qcommon/cm_load.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -567,7 +567,10 @@
==================
*/
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 @@
// 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 @@
, 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 @@
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 ();
Modified: trunk/code/qcommon/cmd.c
===================================================================
--- trunk/code/qcommon/cmd.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/qcommon/cmd.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -239,7 +239,10 @@
===============
*/
void Cmd_Exec_f( void ) {
- char *f;
+ union {
+ char *c;
+ void *v;
+ } f;
int len;
char filename[MAX_QPATH];
@@ -249,17 +252,17 @@
}
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);
}
Modified: trunk/code/qcommon/net_ip.c
===================================================================
--- trunk/code/qcommon/net_ip.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/qcommon/net_ip.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -786,7 +786,7 @@
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 @@
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 @@
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 @@
}
// 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);
Modified: trunk/code/qcommon/q_shared.c
===================================================================
--- trunk/code/qcommon/q_shared.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/qcommon/q_shared.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -710,11 +710,12 @@
return qfalse;
#else
char *p;
+ double d;
if( *s == '\0' )
return qfalse;
- strtod( s, &p );
+ d = strtod( s, &p );
return *p == '\0';
#endif
Modified: trunk/code/qcommon/unzip.c
===================================================================
--- trunk/code/qcommon/unzip.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/qcommon/unzip.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -1109,7 +1109,8 @@
{
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 @@
{
int v;
- fread( &v, sizeof(v), 1, fin );
+ size_t size;
+ size = fread( &v, sizeof(v), 1, fin );
*pX = LittleLong( v);
return UNZ_OK;
Modified: trunk/code/qcommon/vm.c
===================================================================
--- trunk/code/qcommon/vm.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/qcommon/vm.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -218,7 +218,11 @@
*/
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 @@
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 @@
numInstructions = vm->instructionPointersLength >> 2;
// parse the symbols
- text_p = mapfile;
+ text_p = mapfile.c;
prev = &vm->symbols;
count = 0;
@@ -291,7 +295,7 @@
vm->numSymbols = count;
Com_Printf( "%i symbols parsed from %s\n", count, symbols );
- FS_FreeFile( mapfile );
+ FS_FreeFile( mapfile.v );
}
/*
@@ -364,47 +368,50 @@
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 @@
// 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 @@
}
// 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;
}
/*
Modified: trunk/code/renderer/tr_bsp.c
===================================================================
--- trunk/code/renderer/tr_bsp.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_bsp.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -1795,7 +1795,10 @@
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 @@
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 @@
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 @@
// 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 );
}
Modified: trunk/code/renderer/tr_image.c
===================================================================
--- trunk/code/renderer/tr_image.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_image.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -1431,7 +1431,11 @@
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 @@
}
// 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 @@
skin->numSurfaces++;
}
- ri.FS_FreeFile( text );
+ ri.FS_FreeFile( text.v );
// never let a skin have 0 shaders
Modified: trunk/code/renderer/tr_image_bmp.c
===================================================================
--- trunk/code/renderer/tr_image_bmp.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_image_bmp.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -50,7 +50,10 @@
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 @@
//
// 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 @@
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 @@
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 @@
}
}
- ri.FS_FreeFile( buffer );
+ ri.FS_FreeFile( buffer.v );
}
Modified: trunk/code/renderer/tr_image_jpg.c
===================================================================
--- trunk/code/renderer/tr_image_jpg.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_image_jpg.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -57,7 +57,10 @@
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 @@
* 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 @@
/* 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 @@
* 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).
Modified: trunk/code/renderer/tr_image_pcx.c
===================================================================
--- trunk/code/renderer/tr_image_pcx.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_image_pcx.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -50,7 +50,10 @@
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 @@
//
// 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 @@
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 @@
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 @@
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);
Modified: trunk/code/renderer/tr_image_png.c
===================================================================
--- trunk/code/renderer/tr_image_png.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_image_png.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -215,6 +215,10 @@
static struct BufferedFile *ReadBufferedFile(const char *name)
{
struct BufferedFile *BF;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
/*
* input verification
@@ -248,7 +252,8 @@
* 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?
Modified: trunk/code/renderer/tr_image_tga.c
===================================================================
--- trunk/code/renderer/tr_image_tga.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_image_tga.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -45,7 +45,10 @@
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 @@
//
// 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 @@
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 @@
*pic = targa_rgba;
- ri.FS_FreeFile (buffer);
+ ri.FS_FreeFile (buffer.v);
}
Modified: trunk/code/renderer/tr_model.c
===================================================================
--- trunk/code/renderer/tr_model.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/renderer/tr_model.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -83,7 +83,10 @@
*/
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 @@
{
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 @@
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 ) {
Modified: trunk/code/sys/con_tty.c
===================================================================
--- trunk/code/sys/con_tty.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/sys/con_tty.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -86,12 +86,14 @@
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 @@
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 @@
int avail;
char key;
field_t *history;
+ size_t size;
if( ttycon_on )
{
@@ -336,8 +340,8 @@
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 @@
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;
Modified: trunk/code/sys/sys_unix.c
===================================================================
--- trunk/code/sys/sys_unix.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/sys/sys_unix.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -231,7 +231,10 @@
{
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;
Modified: trunk/code/tools/lcc/src/bytecode.c
===================================================================
--- trunk/code/tools/lcc/src/bytecode.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/tools/lcc/src/bytecode.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -261,7 +261,8 @@
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;
}
Modified: trunk/code/ui/ui_shared.c
===================================================================
--- trunk/code/ui/ui_shared.c 2008-11-10 09:47:14 UTC (rev 1486)
+++ trunk/code/ui/ui_shared.c 2008-11-10 23:55:22 UTC (rev 1487)
@@ -5239,9 +5239,16 @@
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;
}
More information about the quake3-commits
mailing list