* Fix some new GCC 4.3 warnings

* Fix many many strict aliasing warnings, now that it's re-enabled
This commit is contained in:
Tim Angus 2008-11-10 23:55:22 +00:00
parent 7c19978aaa
commit 72dea0a184
19 changed files with 220 additions and 152 deletions

View file

@ -620,7 +620,10 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
unsigned short *aptr, *bptr, *cptr, *dptr; unsigned short *aptr, *bptr, *cptr, *dptr;
long y0,y1,y2,y3,cr,cb; long y0,y1,y2,y3,cr,cb;
byte *bbptr, *baptr, *bcptr, *bdptr; 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) { if (!roq_flags) {
two = four = 256; two = four = 256;
@ -663,7 +666,7 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
VQ2TO4(aptr,bptr,cptr,dptr); VQ2TO4(aptr,bptr,cptr,dptr);
} }
} else if (cinTable[currentHandle].samplesPerPixel==4) { } else if (cinTable[currentHandle].samplesPerPixel==4) {
ibptr = (unsigned int *)bptr; ibptr.s = bptr;
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input++; y0 = (long)*input++;
y1 = (long)*input++; y1 = (long)*input++;
@ -671,20 +674,22 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
y3 = (long)*input++; y3 = (long)*input++;
cr = (long)*input++; cr = (long)*input++;
cb = (long)*input++; cb = (long)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y1, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y1, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y2, cr, cb );
*ibptr++ = yuv_to_rgb24( y3, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y3, cr, cb );
} }
icptr = (unsigned int *)vq4; icptr.s = vq4;
idptr = (unsigned int *)vq8; idptr.s = vq8;
for(i=0;i<four;i++) { for(i=0;i<four;i++) {
iaptr = (unsigned int *)vq2 + (*input++)*4; iaptr.s = vq2;
ibptr = (unsigned int *)vq2 + (*input++)*4; iaptr.i += (*input++)*4;
ibptr.s = vq2;
ibptr.i += (*input++)*4;
for(j=0;j<2;j++) 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) { } else if (cinTable[currentHandle].samplesPerPixel==1) {
bbptr = (byte *)bptr; bbptr = (byte *)bptr;
@ -739,7 +744,7 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
} }
} }
} else if (cinTable[currentHandle].samplesPerPixel==4) { } else if (cinTable[currentHandle].samplesPerPixel==4) {
ibptr = (unsigned int *)bptr; ibptr.s = bptr;
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input++; y0 = (long)*input++;
y1 = (long)*input++; y1 = (long)*input++;
@ -747,25 +752,27 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
y3 = (long)*input++; y3 = (long)*input++;
cr = (long)*input++; cr = (long)*input++;
cb = (long)*input++; cb = (long)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y1, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y1, cr, cb );
*ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb ); *ibptr.i++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb );
*ibptr++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb ); *ibptr.i++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb );
*ibptr++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb ); *ibptr.i++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb );
*ibptr++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb ); *ibptr.i++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y2, cr, cb );
*ibptr++ = yuv_to_rgb24( y3, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y3, cr, cb );
} }
icptr = (unsigned int *)vq4; icptr.s = vq4;
idptr = (unsigned int *)vq8; idptr.s = vq8;
for(i=0;i<four;i++) { for(i=0;i<four;i++) {
iaptr = (unsigned int *)vq2 + (*input++)*8; iaptr.s = vq2;
ibptr = (unsigned int *)vq2 + (*input++)*8; iaptr.i += (*input++)*8;
ibptr.s = vq2;
ibptr.i += (*input++)*8;
for(j=0;j<2;j++) { for(j=0;j<2;j++) {
VQ2TO4(iaptr, ibptr, icptr, idptr); VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i);
VQ2TO4(iaptr, ibptr, icptr, idptr); VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i);
} }
} }
} else if (cinTable[currentHandle].samplesPerPixel==1) { } 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) { } else if (cinTable[currentHandle].samplesPerPixel == 4) {
ibptr = (unsigned int *) bptr; ibptr.s = bptr;
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input; input+=2; y0 = (long)*input; input+=2;
y2 = (long)*input; input+=2; y2 = (long)*input; input+=2;
cr = (long)*input++; cr = (long)*input++;
cb = (long)*input++; cb = (long)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb ); *ibptr.i++ = yuv_to_rgb24( y2, cr, cb );
} }
icptr = (unsigned int *)vq4; icptr.s = vq4;
idptr = (unsigned int *)vq8; idptr.s = vq8;
for(i=0;i<four;i++) { for(i=0;i<four;i++) {
iaptr = (unsigned int *)vq2 + (*input++)*2; iaptr.s = vq2;
ibptr = (unsigned int *)vq2 + (*input++)*2; iaptr.i += (*input++)*2;
ibptr.s = vq2 + (*input++)*2;
ibptr.i += (*input++)*2;
for(j=0;j<2;j++) { for(j=0;j<2;j++) {
VQ2TO2(iaptr,ibptr,icptr,idptr); VQ2TO2(iaptr.i,ibptr.i,icptr.i,idptr.i);
} }
} }
} }

View file

@ -567,7 +567,10 @@ Loads in the map and all submodels
================== ==================
*/ */
void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) { void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
int *buf; union {
int *i;
void *v;
} buf;
int i; int i;
dheader_t header; dheader_t header;
int length; int length;
@ -606,19 +609,19 @@ void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
// load the file // load the file
// //
#ifndef BSPC #ifndef BSPC
length = FS_ReadFile( name, (void **)&buf ); length = FS_ReadFile( name, &buf.v );
#else #else
length = LoadQuakeFile((quakefile_t *) name, (void **)&buf); length = LoadQuakeFile((quakefile_t *) name, &buf.v);
#endif #endif
if ( !buf ) { if ( !buf.i ) {
Com_Error (ERR_DROP, "Couldn't load %s", name); 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; *checksum = last_checksum;
header = *(dheader_t *)buf; header = *(dheader_t *)buf.i;
for (i=0 ; i<sizeof(dheader_t)/4 ; i++) { for (i=0 ; i<sizeof(dheader_t)/4 ; i++) {
((int *)&header)[i] = LittleLong ( ((int *)&header)[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 ); , name, header.version, BSP_VERSION );
} }
cmod_base = (byte *)buf; cmod_base = (byte *)buf.i;
// load into heap // load into heap
CMod_LoadShaders( &header.lumps[LUMP_SHADERS] ); 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] ); CMod_LoadPatches( &header.lumps[LUMP_SURFACES], &header.lumps[LUMP_DRAWVERTS] );
// we are NOT freeing the file, because it is cached for the ref // we are NOT freeing the file, because it is cached for the ref
FS_FreeFile (buf); FS_FreeFile (buf.v);
CM_InitBoxHull (); CM_InitBoxHull ();

View file

@ -239,7 +239,10 @@ Cmd_Exec_f
=============== ===============
*/ */
void Cmd_Exec_f( void ) { void Cmd_Exec_f( void ) {
char *f; union {
char *c;
void *v;
} f;
int len; int len;
char filename[MAX_QPATH]; char filename[MAX_QPATH];
@ -250,16 +253,16 @@ void Cmd_Exec_f( void ) {
Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) ); Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
COM_DefaultExtension( filename, sizeof( filename ), ".cfg" ); COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
len = FS_ReadFile( filename, (void **)&f); len = FS_ReadFile( filename, &f.v);
if (!f) { if (!f.c) {
Com_Printf ("couldn't exec %s\n",Cmd_Argv(1)); Com_Printf ("couldn't exec %s\n",Cmd_Argv(1));
return; return;
} }
Com_Printf ("execing %s\n",Cmd_Argv(1)); Com_Printf ("execing %s\n",Cmd_Argv(1));
Cbuf_InsertText (f); Cbuf_InsertText (f.c);
FS_FreeFile (f); FS_FreeFile (f.v);
} }

View file

@ -786,7 +786,7 @@ NET_IPSocket
int NET_IPSocket( char *net_interface, int port, int *err ) { int NET_IPSocket( char *net_interface, int port, int *err ) {
SOCKET newsocket; SOCKET newsocket;
struct sockaddr_in address; struct sockaddr_in address;
qboolean _true = qtrue; u_long _true = 1;
int i = 1; int i = 1;
*err = 0; *err = 0;
@ -804,7 +804,7 @@ int NET_IPSocket( char *net_interface, int port, int *err ) {
return newsocket; return newsocket;
} }
// make it non-blocking // 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() ); Com_Printf( "WARNING: NET_IPSocket: ioctl FIONBIO: %s\n", NET_ErrorString() );
*err = socketError; *err = socketError;
closesocket(newsocket); closesocket(newsocket);
@ -857,7 +857,7 @@ NET_IP6Socket
int NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, int *err ) { int NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, int *err ) {
SOCKET newsocket; SOCKET newsocket;
struct sockaddr_in6 address; struct sockaddr_in6 address;
qboolean _true = qtrue; u_long _true = 1;
*err = 0; *err = 0;
@ -879,7 +879,7 @@ int NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, i
} }
// make it non-blocking // 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() ); Com_Printf( "WARNING: NET_IP6Socket: ioctl FIONBIO: %s\n", NET_ErrorString() );
*err = socketError; *err = socketError;
closesocket(newsocket); closesocket(newsocket);

View file

@ -710,11 +710,12 @@ qboolean Q_isanumber( const char *s )
return qfalse; return qfalse;
#else #else
char *p; char *p;
double d;
if( *s == '\0' ) if( *s == '\0' )
return qfalse; return qfalse;
strtod( s, &p ); d = strtod( s, &p );
return *p == '\0'; return *p == '\0';
#endif #endif

View file

@ -1109,7 +1109,8 @@ static int unzlocal_getShort (FILE* fin, uLong *pX)
{ {
short v; short v;
fread( &v, sizeof(v), 1, fin ); size_t size;
size = fread( &v, sizeof(v), 1, fin );
*pX = LittleShort( v); *pX = LittleShort( v);
return UNZ_OK; return UNZ_OK;
@ -1138,7 +1139,8 @@ static int unzlocal_getLong (FILE *fin, uLong *pX)
{ {
int v; int v;
fread( &v, sizeof(v), 1, fin ); size_t size;
size = fread( &v, sizeof(v), 1, fin );
*pX = LittleLong( v); *pX = LittleLong( v);
return UNZ_OK; return UNZ_OK;

View file

@ -218,7 +218,11 @@ VM_LoadSymbols
*/ */
void VM_LoadSymbols( vm_t *vm ) { void VM_LoadSymbols( vm_t *vm ) {
int len; int len;
char *mapfile, *text_p, *token; union {
char *c;
void *v;
} mapfile;
char *text_p, *token;
char name[MAX_QPATH]; char name[MAX_QPATH];
char symbols[MAX_QPATH]; char symbols[MAX_QPATH];
vmSymbol_t **prev, *sym; vmSymbol_t **prev, *sym;
@ -235,8 +239,8 @@ void VM_LoadSymbols( vm_t *vm ) {
COM_StripExtension(vm->name, name, sizeof(name)); COM_StripExtension(vm->name, name, sizeof(name));
Com_sprintf( symbols, sizeof( symbols ), "vm/%s.map", name ); Com_sprintf( symbols, sizeof( symbols ), "vm/%s.map", name );
len = FS_ReadFile( symbols, (void **)&mapfile ); len = FS_ReadFile( symbols, &mapfile.v );
if ( !mapfile ) { if ( !mapfile.c ) {
Com_Printf( "Couldn't load symbol file: %s\n", symbols ); Com_Printf( "Couldn't load symbol file: %s\n", symbols );
return; return;
} }
@ -244,7 +248,7 @@ void VM_LoadSymbols( vm_t *vm ) {
numInstructions = vm->instructionPointersLength >> 2; numInstructions = vm->instructionPointersLength >> 2;
// parse the symbols // parse the symbols
text_p = mapfile; text_p = mapfile.c;
prev = &vm->symbols; prev = &vm->symbols;
count = 0; count = 0;
@ -291,7 +295,7 @@ void VM_LoadSymbols( vm_t *vm ) {
vm->numSymbols = count; vm->numSymbols = count;
Com_Printf( "%i symbols parsed from %s\n", count, symbols ); 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 dataLength;
int i; int i;
char filename[MAX_QPATH]; char filename[MAX_QPATH];
vmHeader_t *header; union {
vmHeader_t *h;
void *v;
} header;
// load the image // load the image
Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", vm->name ); Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", vm->name );
Com_Printf( "Loading vm file %s...\n", filename ); Com_Printf( "Loading vm file %s...\n", filename );
length = FS_ReadFile( filename, (void **)&header ); length = FS_ReadFile( filename, &header.v );
if ( !header ) { if ( !header.h ) {
Com_Printf( "Failed.\n" ); Com_Printf( "Failed.\n" );
VM_Free( vm ); VM_Free( vm );
return NULL; 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" ); Com_Printf( "...which has vmMagic VM_MAGIC_VER2\n" );
// byte swap the header // byte swap the header
for ( i = 0 ; i < sizeof( vmHeader_t ) / 4 ; i++ ) { 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 // validate
if ( header->jtrgLength < 0 if ( header.h->jtrgLength < 0
|| header->bssLength < 0 || header.h->bssLength < 0
|| header->dataLength < 0 || header.h->dataLength < 0
|| header->litLength < 0 || header.h->litLength < 0
|| header->codeLength <= 0 ) { || header.h->codeLength <= 0 ) {
VM_Free( vm ); VM_Free( vm );
Com_Error( ERR_FATAL, "%s has bad header", filename ); 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 // byte swap the header
// sizeof( vmHeader_t ) - sizeof( int ) is the 1.32b vm header size // sizeof( vmHeader_t ) - sizeof( int ) is the 1.32b vm header size
for ( i = 0 ; i < ( sizeof( vmHeader_t ) - sizeof( int ) ) / 4 ; i++ ) { 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 // validate
if ( header->bssLength < 0 if ( header.h->bssLength < 0
|| header->dataLength < 0 || header.h->dataLength < 0
|| header->litLength < 0 || header.h->litLength < 0
|| header->codeLength <= 0 ) { || header.h->codeLength <= 0 ) {
VM_Free( vm ); VM_Free( vm );
Com_Error( ERR_FATAL, "%s has bad header", filename ); 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 // round up to next power of 2 so all data operations can
// be mask protected // 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++ ) { for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {
} }
dataLength = 1 << i; dataLength = 1 << i;
@ -431,33 +438,34 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
} }
// copy the intialized data // 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 // 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 ) ); *(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) );
} }
if( header->vmMagic == VM_MAGIC_VER2 ) { if( header.h->vmMagic == VM_MAGIC_VER2 ) {
vm->numJumpTableTargets = header->jtrgLength >> 2; vm->numJumpTableTargets = header.h->jtrgLength >> 2;
Com_Printf( "Loading %d jump table targets\n", vm->numJumpTableTargets ); Com_Printf( "Loading %d jump table targets\n", vm->numJumpTableTargets );
if( alloc ) { if( alloc ) {
vm->jumpTableTargets = Hunk_Alloc( header->jtrgLength, h_high ); vm->jumpTableTargets = Hunk_Alloc( header.h->jtrgLength, h_high );
} else { } else {
Com_Memset( vm->jumpTableTargets, 0, header->jtrgLength ); Com_Memset( vm->jumpTableTargets, 0, header.h->jtrgLength );
} }
Com_Memcpy( vm->jumpTableTargets, (byte *)header + header->dataOffset + Com_Memcpy( vm->jumpTableTargets, (byte *)header.h + header.h->dataOffset +
header->dataLength + header->litLength, header->jtrgLength ); header.h->dataLength + header.h->litLength, header.h->jtrgLength );
// byte swap the longs // 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 ) ); *(int *)(vm->jumpTableTargets + i) = LittleLong( *(int *)(vm->jumpTableTargets + i ) );
} }
} }
return header; return header.h;
} }
/* /*

View file

@ -1795,7 +1795,10 @@ Called directly from cgame
void RE_LoadWorldMap( const char *name ) { void RE_LoadWorldMap( const char *name ) {
int i; int i;
dheader_t *header; dheader_t *header;
byte *buffer; union {
byte *b;
void *v;
} buffer;
byte *startMarker; byte *startMarker;
if ( tr.worldMapLoaded ) { if ( tr.worldMapLoaded ) {
@ -1813,8 +1816,8 @@ void RE_LoadWorldMap( const char *name ) {
tr.worldMapLoaded = qtrue; tr.worldMapLoaded = qtrue;
// load it // load it
ri.FS_ReadFile( name, (void **)&buffer ); ri.FS_ReadFile( name, &buffer.v );
if ( !buffer ) { if ( !buffer.b ) {
ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); 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); startMarker = ri.Hunk_Alloc(0, h_low);
c_gridVerts = 0; c_gridVerts = 0;
header = (dheader_t *)buffer; header = (dheader_t *)buffer.b;
fileBase = (byte *)header; fileBase = (byte *)header;
i = LittleLong (header->version); 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 // only set tr.world now that we know the entire level has loaded properly
tr.world = &s_worldData; tr.world = &s_worldData;
ri.FS_FreeFile( buffer ); ri.FS_FreeFile( buffer.v );
} }

View file

@ -1431,7 +1431,11 @@ qhandle_t RE_RegisterSkin( const char *name ) {
qhandle_t hSkin; qhandle_t hSkin;
skin_t *skin; skin_t *skin;
skinSurface_t *surf; skinSurface_t *surf;
char *text, *text_p; union {
char *c;
void *v;
} text;
char *text_p;
char *token; char *token;
char surfName[MAX_QPATH]; char surfName[MAX_QPATH];
@ -1480,12 +1484,12 @@ qhandle_t RE_RegisterSkin( const char *name ) {
} }
// load and parse the skin file // load and parse the skin file
ri.FS_ReadFile( name, (void **)&text ); ri.FS_ReadFile( name, &text.v );
if ( !text ) { if ( !text.c ) {
return 0; return 0;
} }
text_p = text; text_p = text.c;
while ( text_p && *text_p ) { while ( text_p && *text_p ) {
// get surface name // get surface name
token = CommaParse( &text_p ); token = CommaParse( &text_p );
@ -1514,7 +1518,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
skin->numSurfaces++; skin->numSurfaces++;
} }
ri.FS_FreeFile( text ); ri.FS_FreeFile( text.v );
// never let a skin have 0 shaders // never let a skin have 0 shaders

View file

@ -50,7 +50,10 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
int row, column; int row, column;
byte *buf_p; byte *buf_p;
byte *end; byte *end;
byte *buffer = NULL; union {
byte *b;
void *v;
} buffer;
int length; int length;
BMPHeader_t bmpHeader; BMPHeader_t bmpHeader;
byte *bmpRGBA; byte *bmpRGBA;
@ -66,8 +69,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
// //
// load the file // load the file
// //
length = ri.FS_ReadFile( ( char * ) name, (void **)&buffer); length = ri.FS_ReadFile( ( char * ) name, &buffer.v);
if (!buffer || length < 0) { if (!buffer.b || length < 0) {
return; 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 ); ri.Error( ERR_DROP, "LoadBMP: header too short (%s)\n", name );
} }
buf_p = buffer; buf_p = buffer.b;
end = buffer + length; end = buffer.b + length;
bmpHeader.id[0] = *buf_p++; bmpHeader.id[0] = *buf_p++;
bmpHeader.id[1] = *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); 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 ); 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' ) 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 );
} }

View file

@ -57,7 +57,10 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
unsigned pixelcount, memcount; unsigned pixelcount, memcount;
unsigned char *out; unsigned char *out;
int len; int len;
byte *fbuffer; union {
byte *b;
void *v;
} fbuffer;
byte *buf; byte *buf;
/* In this example we want to open the input file before doing anything else, /* 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. * requires it in order to read binary files.
*/ */
len = ri.FS_ReadFile ( ( char * ) filename, (void **)&fbuffer); len = ri.FS_ReadFile ( ( char * ) filename, &fbuffer.v);
if (!fbuffer || len < 0) { if (!fbuffer.b || len < 0) {
return; 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) */ /* 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() */ /* 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 * 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...) * 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 /* At this point you may want to check to see whether any corrupt-data
* warnings occurred (test whether jerr.pub.num_warnings is nonzero). * warnings occurred (test whether jerr.pub.num_warnings is nonzero).

View file

@ -50,7 +50,10 @@ typedef struct {
void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height) void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
{ {
byte *raw; union {
byte *b;
void *v;
} raw;
byte *end; byte *end;
pcx_t *pcx; pcx_t *pcx;
int len; int len;
@ -71,23 +74,23 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
// //
// load the file // load the file
// //
len = ri.FS_ReadFile( ( char * ) filename, (void **)&raw); len = ri.FS_ReadFile( ( char * ) filename, &raw.v);
if (!raw || len < 0) { if (!raw.b || len < 0) {
return; return;
} }
if((unsigned)len < sizeof(pcx_t)) if((unsigned)len < sizeof(pcx_t))
{ {
ri.Printf (PRINT_ALL, "PCX truncated: %s\n", filename); ri.Printf (PRINT_ALL, "PCX truncated: %s\n", filename);
ri.FS_FreeFile (raw); ri.FS_FreeFile (raw.v);
return; return;
} }
// //
// parse the PCX file // parse the PCX file
// //
pcx = (pcx_t *)raw; pcx = (pcx_t *)raw.b;
end = raw+len; end = raw.b+len;
w = LittleShort(pcx->xmax)+1; w = LittleShort(pcx->xmax)+1;
h = LittleShort(pcx->ymax)+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 ); 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 // FIXME: should use bytes_per_line but original q3 didn't do that either
while(pix < pic8+size) while(pix < pic8+size)
{ {
@ -117,16 +120,16 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
continue; continue;
} }
if(raw+1 > end) if(raw.b+1 > end)
break; break;
dataByte = *raw++; dataByte = *raw.b++;
if((dataByte & 0xC0) == 0xC0) if((dataByte & 0xC0) == 0xC0)
{ {
if(raw+1 > end) if(raw.b+1 > end)
break; break;
runLength = dataByte & 0x3F; runLength = dataByte & 0x3F;
dataByte = *raw++; dataByte = *raw.b++;
} }
else else
runLength = 1; runLength = 1;
@ -139,7 +142,7 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
ri.Free (pic8); 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.Printf (PRINT_ALL, "PCX missing palette: %s\n", filename);
ri.FS_FreeFile (pcx); ri.FS_FreeFile (pcx);

View file

@ -215,6 +215,10 @@ struct BufferedFile
static struct BufferedFile *ReadBufferedFile(const char *name) static struct BufferedFile *ReadBufferedFile(const char *name)
{ {
struct BufferedFile *BF; struct BufferedFile *BF;
union {
byte *b;
void *v;
} buffer;
/* /*
* input verification * input verification
@ -248,7 +252,8 @@ static struct BufferedFile *ReadBufferedFile(const char *name)
* Read the file. * 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? * Did we get it? Is it big enough?

View file

@ -45,7 +45,10 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
int row, column; int row, column;
byte *buf_p; byte *buf_p;
byte *end; byte *end;
byte *buffer = NULL; union {
byte *b;
void *v;
} buffer;
TargaHeader targa_header; TargaHeader targa_header;
byte *targa_rgba; byte *targa_rgba;
int length; int length;
@ -60,8 +63,8 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
// //
// load the file // load the file
// //
length = ri.FS_ReadFile ( ( char * ) name, (void **)&buffer); length = ri.FS_ReadFile ( ( char * ) name, &buffer.v);
if (!buffer || length < 0) { if (!buffer.b || length < 0) {
return; 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 ); ri.Error( ERR_DROP, "LoadTGA: header too short (%s)\n", name );
} }
buf_p = buffer; buf_p = buffer.b;
end = buffer + length; end = buffer.b + length;
targa_header.id_length = buf_p[0]; targa_header.id_length = buf_p[0];
targa_header.colormap_type = buf_p[1]; 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; *pic = targa_rgba;
ri.FS_FreeFile (buffer); ri.FS_FreeFile (buffer.v);
} }

View file

@ -83,7 +83,10 @@ asked for again.
*/ */
qhandle_t RE_RegisterModel( const char *name ) { qhandle_t RE_RegisterModel( const char *name ) {
model_t *mod; model_t *mod;
unsigned *buf; union {
unsigned *u;
void *v;
} buf;
int lod; int lod;
int ident; int ident;
qboolean loaded = qfalse; qboolean loaded = qfalse;
@ -151,19 +154,19 @@ qhandle_t RE_RegisterModel( const char *name ) {
{ {
int filesize; int filesize;
filesize = ri.FS_ReadFile(name, (void **) &buf); filesize = ri.FS_ReadFile(name, (void **) &buf.v);
if(!buf) if(!buf.u)
{ {
ri.Printf (PRINT_WARNING,"RE_RegisterModel: couldn't load %s\n", name); ri.Printf (PRINT_WARNING,"RE_RegisterModel: couldn't load %s\n", name);
mod->type = MOD_BAD; mod->type = MOD_BAD;
return 0; return 0;
} }
ident = LittleLong(*(unsigned *)buf); ident = LittleLong(*(unsigned *)buf.u);
if(ident == MDR_IDENT) 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) if(!loaded)
{ {
@ -184,26 +187,26 @@ qhandle_t RE_RegisterModel( const char *name ) {
else else
Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext);
ri.FS_ReadFile( namebuf, (void **)&buf ); ri.FS_ReadFile( namebuf, &buf.v );
if ( !buf ) { if ( !buf.u ) {
continue; continue;
} }
loadmodel = mod; loadmodel = mod;
ident = LittleLong(*(unsigned *)buf); ident = LittleLong(*(unsigned *)buf.u);
if ( ident == MD4_IDENT ) { if ( ident == MD4_IDENT ) {
loaded = R_LoadMD4( mod, buf, name ); loaded = R_LoadMD4( mod, buf.u, name );
} else { } else {
if ( ident != MD3_IDENT ) { if ( ident != MD3_IDENT ) {
ri.Printf (PRINT_WARNING,"RE_RegisterModel: unknown fileid for %s\n", name); ri.Printf (PRINT_WARNING,"RE_RegisterModel: unknown fileid for %s\n", name);
goto fail; 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 ( !loaded ) {
if ( lod == 0 ) { if ( lod == 0 ) {

View file

@ -86,12 +86,14 @@ send "\b \b"
static void CON_Back( void ) static void CON_Back( void )
{ {
char key; char key;
size_t size;
key = '\b'; key = '\b';
write(1, &key, 1); size = write(1, &key, 1);
key = ' '; key = ' ';
write(1, &key, 1); size = write(1, &key, 1);
key = '\b'; key = '\b';
write(1, &key, 1); size = write(1, &key, 1);
} }
/* /*
@ -142,12 +144,13 @@ static void CON_Show( void )
ttycon_hide--; ttycon_hide--;
if (ttycon_hide == 0) if (ttycon_hide == 0)
{ {
write( 1, "]", 1 ); size_t size;
size = write( 1, "]", 1 );
if (TTY_con.cursor) if (TTY_con.cursor)
{ {
for (i=0; i<TTY_con.cursor; i++) 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; int avail;
char key; char key;
field_t *history; field_t *history;
size_t size;
if( ttycon_on ) if( ttycon_on )
{ {
@ -336,8 +340,8 @@ char *CON_Input( void )
strcpy(text, TTY_con.buffer); strcpy(text, TTY_con.buffer);
Field_Clear(&TTY_con); Field_Clear(&TTY_con);
key = '\n'; key = '\n';
write(1, &key, 1); size = write(1, &key, 1);
write( 1, "]", 1 ); size = write( 1, "]", 1 );
return text; return text;
} }
if (key == '\t') if (key == '\t')
@ -399,7 +403,7 @@ char *CON_Input( void )
TTY_con.buffer[TTY_con.cursor] = key; TTY_con.buffer[TTY_con.cursor] = key;
TTY_con.cursor++; TTY_con.cursor++;
// print the current line (this is differential) // print the current line (this is differential)
write(1, &key, 1); size = write(1, &key, 1);
} }
return NULL; return NULL;

View file

@ -231,7 +231,10 @@ char *Sys_Cwd( void )
{ {
static char cwd[MAX_OSPATH]; 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; cwd[MAX_OSPATH-1] = 0;
return cwd; return cwd;

View file

@ -261,7 +261,8 @@ static void LoadSourceFile( const char *filename ) {
length = filelength( f ); length = filelength( f );
sourceFile = malloc( length + 1 ); sourceFile = malloc( length + 1 );
if ( sourceFile ) { if ( sourceFile ) {
fread( sourceFile, length, 1, f ); size_t size;
size = fread( sourceFile, length, 1, f );
sourceFile[length] = 0; sourceFile[length] = 0;
} }

View file

@ -5239,9 +5239,16 @@ qboolean MenuParse_name( itemDef_t *item, int handle ) {
qboolean MenuParse_fullscreen( itemDef_t *item, int handle ) { qboolean MenuParse_fullscreen( itemDef_t *item, int handle ) {
menuDef_t *menu = (menuDef_t*)item; 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; return qfalse;
} }
menu->fullScreen = fullScreen.b;
return qtrue; return qtrue;
} }