* 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

@ -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 );
}

View file

@ -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

View file

@ -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 );
}

View file

@ -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).

View file

@ -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);

View file

@ -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?

View file

@ -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);
}

View file

@ -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 ) {