Browse Source

public,sprites: fix -Wcast-align, disable -Werror for it

pull/2/head
mittorn 4 years ago
parent
commit
341e440c07
  1. 12
      public/crclib.c
  2. 2
      public/crclib.h
  3. 2
      ref_gl/gl_dbghulls.c
  4. 8
      ref_gl/gl_sprite.c
  5. 2
      wscript

12
public/crclib.c

@ -259,7 +259,7 @@ void MD5Update( MD5Context_t *ctx, const byte *buf, uint len )
} }
memcpy( p, buf, t ); memcpy( p, buf, t );
MD5Transform( ctx->buf, (uint *)ctx->in ); MD5Transform( ctx->buf, ctx->in );
buf += t; buf += t;
len -= t; len -= t;
} }
@ -268,7 +268,7 @@ void MD5Update( MD5Context_t *ctx, const byte *buf, uint len )
while( len >= 64 ) while( len >= 64 )
{ {
memcpy( ctx->in, buf, 64 ); memcpy( ctx->in, buf, 64 );
MD5Transform( ctx->buf, (uint *)ctx->in ); MD5Transform( ctx->buf, ctx->in );
buf += 64; buf += 64;
len -= 64; len -= 64;
} }
@ -307,7 +307,7 @@ void MD5Final( byte digest[16], MD5Context_t *ctx )
// two lots of padding: pad the first block to 64 bytes // two lots of padding: pad the first block to 64 bytes
memset( p, 0, count ); memset( p, 0, count );
MD5Transform( ctx->buf, (uint *)ctx->in ); MD5Transform( ctx->buf, ctx->in );
// now fill the next block with 56 bytes // now fill the next block with 56 bytes
memset( ctx->in, 0, 56 ); memset( ctx->in, 0, 56 );
@ -319,10 +319,10 @@ void MD5Final( byte digest[16], MD5Context_t *ctx )
} }
// append length in bits and transform // append length in bits and transform
((uint *)ctx->in)[14] = ctx->bits[0]; ctx->in[14] = ctx->bits[0];
((uint *)ctx->in)[15] = ctx->bits[1]; ctx->in[15] = ctx->bits[1];
MD5Transform( ctx->buf, (uint *)ctx->in ); MD5Transform( ctx->buf, ctx->in );
memcpy( digest, ctx->buf, 16 ); memcpy( digest, ctx->buf, 16 );
memset( ctx, 0, sizeof( *ctx )); // in case it's sensitive memset( ctx, 0, sizeof( *ctx )); // in case it's sensitive
} }

2
public/crclib.h

@ -23,7 +23,7 @@ typedef struct
{ {
uint buf[4]; uint buf[4];
uint bits[2]; uint bits[2];
byte in[64]; uint in[16];
} MD5Context_t; } MD5Context_t;

2
ref_gl/gl_dbghulls.c

@ -17,7 +17,7 @@ GNU General Public License for more details.
#include "mod_local.h" #include "mod_local.h"
#define list_entry( ptr, type, member ) \ #define list_entry( ptr, type, member ) \
((type *)((char *)(ptr) - (size_t)(&((type *)0)->member))) ((type *)((void *)(ptr) - (size_t)(&((type *)0)->member)))
// iterate over each entry in the list // iterate over each entry in the list
#define list_for_each_entry( pos, head, member ) \ #define list_for_each_entry( pos, head, member ) \

8
ref_gl/gl_sprite.c

@ -87,7 +87,7 @@ static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, msp
pspriteframe->gl_texturenum = gl_texturenum; pspriteframe->gl_texturenum = gl_texturenum;
*ppframe = pspriteframe; *ppframe = pspriteframe;
return ( const dframetype_t* )(( const byte* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes ); return ( const dframetype_t* )(( const void* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes );
} }
/* /*
@ -157,7 +157,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
if( pin->version == SPRITE_VERSION_Q1 || pin->version == SPRITE_VERSION_32 ) if( pin->version == SPRITE_VERSION_Q1 || pin->version == SPRITE_VERSION_32 )
numi = NULL; numi = NULL;
else if( pin->version == SPRITE_VERSION_HL ) else if( pin->version == SPRITE_VERSION_HL )
numi = (const short *)((const byte*)buffer + sizeof( dsprite_hl_t )); numi = (const short *)(void *)((const byte*)buffer + sizeof( dsprite_hl_t ));
r_texFlags = texFlags; r_texFlags = texFlags;
sprite_version = pin->version; sprite_version = pin->version;
@ -169,7 +169,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
rgbdata_t *pal; rgbdata_t *pal;
pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 ); pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 );
pframetype = (const dframetype_t *)((const byte*)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1 pframetype = (const dframetype_t *)(void *)((const byte*)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
} }
else if( *numi == 256 ) else if( *numi == 256 )
@ -191,7 +191,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
break; break;
} }
pframetype = (const dframetype_t *)(src + 768); pframetype = (const dframetype_t *)(void *)(src + 768);
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
} }
else else

2
wscript

@ -271,7 +271,7 @@ def configure(conf):
'-Werror=duplicated-branches', # BEWARE: buggy '-Werror=duplicated-branches', # BEWARE: buggy
'-Werror=bool-compare', '-Werror=bool-compare',
'-Werror=bool-operation', '-Werror=bool-operation',
'-Werror=cast-align', '-Wcast-align',
'-Werror=cast-align=strict', # =strict is for GCC >=8 '-Werror=cast-align=strict', # =strict is for GCC >=8
'-Werror=packed', '-Werror=packed',
'-Werror=packed-not-aligned', '-Werror=packed-not-aligned',

Loading…
Cancel
Save