Fix a few strict aliasing warnings

gcc 13 got a little stricter on those (at least with gnu2x/c2x).
This commit is contained in:
Bill Currie 2023-06-13 18:13:23 +09:00
parent db889e5e54
commit 9d1c07d2ac
4 changed files with 42 additions and 30 deletions

View file

@ -413,7 +413,7 @@ gl_R_InitSky (texture_t *mt)
// make an average value for the back to avoid a fringe on the top level
r = g = b = 0;
for (i = 0; i < 128; i++)
for (i = 0; i < 128; i++) {
for (j = 0; j < 128; j++) {
p = src[i * 256 + j + 128];
rgba = &d_8to24table[p];
@ -422,11 +422,13 @@ gl_R_InitSky (texture_t *mt)
g += ((byte *) rgba)[1];
b += ((byte *) rgba)[2];
}
}
r /= 128 * 128;
g /= 128 * 128;
b /= 128 * 128;
((byte *) & transpix)[0] = r / (128 * 128);
((byte *) & transpix)[1] = g / (128 * 128);
((byte *) & transpix)[2] = b / (128 * 128);
((byte *) & transpix)[3] = 0;
//FIXME assumes little endian
transpix = ((b << 16) | (g << 8) | (r << 0)) & 0x00ffffff;
if (!gl_solidskytexture) {
qfglGenTextures (1, &gl_solidskytexture);

View file

@ -57,6 +57,10 @@
#include "r_internal.h"
typedef struct pic_data_s {
subpic_t *subpic;
} picdata_t;
typedef struct cachepic_s {
struct cachepic_s *next;
char *name;
@ -155,12 +159,12 @@ make_glpic (const char *name, qpic_t *p)
qpic_t *pic = 0;
if (p) {
pic = malloc (sizeof (qpic_t) + sizeof (subpic_t *));
pic = malloc (field_offset (qpic_t, data[sizeof (picdata_t)]));
pic->width = p->width;
pic->height = p->height;
subpic_t *sp = GLSL_ScrapSubpic (draw_scrap, pic->width, pic->height);
*(subpic_t **) pic->data = sp;
GLSL_SubpicUpdate (sp, p->data, 1);
__auto_type pd = (picdata_t *) pic->data;
pd->subpic = GLSL_ScrapSubpic (draw_scrap, pic->width, pic->height);
GLSL_SubpicUpdate (pd->subpic, p->data, 1);
}
return pic;
}
@ -172,9 +176,9 @@ pic_free (qpic_t *pic)
return;
}
subpic_t *subpic = *(subpic_t **) pic->data;
__auto_type pd = (picdata_t *) pic->data;
GLSL_SubpicDelete (subpic);
GLSL_SubpicDelete (pd->subpic);
free (pic);
}
@ -225,7 +229,8 @@ make_quad (qpic_t *pic, float x, float y, int w, int h,
int srcx, int srcy, int srcw, int srch, drawvert_t verts[6],
float *color)
{
subpic_t *sp = *(subpic_t **) pic->data;
__auto_type pd = (picdata_t *) pic->data;
subpic_t *sp = pd->subpic;
float sl, sh, tl, th;
srcx += sp->rect->x;
@ -749,11 +754,12 @@ void
glsl_Draw_TileClear (int x, int y, int w, int h)
{
static quat_t color = { 1, 1, 1, 1 };
vrect_t *tile_rect = VRect_New (x, y, w, h);
vrect_t *sub = VRect_New (0, 0, 0, 0); // filled in later;
subpic_t *sp = *(subpic_t **) backtile_pic->data;
int sub_sx, sub_sy, sub_ex, sub_ey;
int i, j;
vrect_t *tile_rect = VRect_New (x, y, w, h);
vrect_t *sub = VRect_New (0, 0, 0, 0); // filled in later;
__auto_type pd = (picdata_t *) backtile_pic->data;
subpic_t *sp = pd->subpic;
int sub_sx, sub_sy, sub_ex, sub_ey;
int i, j;
sub_sx = x / sp->width;
sub_sy = y / sp->height;
@ -792,7 +798,8 @@ glsl_Draw_Fill (int x, int y, int w, int h, int c)
void
glsl_Draw_Line (int x0, int y0, int x1, int y1, int c)
{
subpic_t *sp = *(subpic_t **) white_pic->data;
__auto_type pd = (picdata_t *) white_pic->data;
subpic_t *sp = pd->subpic;
float sl = sp->rect->x * sp->size;
float sh = sp->rect->x * sp->size;
float tl = sp->rect->y * sp->size;

View file

@ -288,12 +288,14 @@ QW_SendHearts (int sock, msghdr_t *msghdr, server_t *servers, int serverlen)
for (i = 0; i < serverlen; i++) {
if (servers[i].updated != 0) {
unsigned char *p = out + (cpos * 6);
p[0] = ((unsigned char *) &servers[i].addr.sin_addr.s_addr)[0];
p[1] = ((unsigned char *) &servers[i].addr.sin_addr.s_addr)[1];
p[2] = ((unsigned char *) &servers[i].addr.sin_addr.s_addr)[2];
p[3] = ((unsigned char *) &servers[i].addr.sin_addr.s_addr)[3];
p[4] = (unsigned char) (ntohs (servers[i].addr.sin_port) >> 8);
p[5] = (unsigned char) (ntohs (servers[i].addr.sin_port) & 0xFF);
in_addr_t addr = ntohl (servers[i].addr.sin_addr.s_addr);
in_port_t port = ntohs (servers[i].addr.sin_port);
p[0] = addr >> 24;
p[1] = addr >> 16;
p[2] = addr >> 8;
p[3] = addr >> 0;
p[4] = port >> 8;
p[5] = port >> 0;
++cpos;
}
}

View file

@ -74,16 +74,17 @@ LoadTriangleList (char *filename, triangle_t **pptri, int *numtriangles)
{
QFile *input;
char name[256], tex[256];
float start, exitpattern, t;
float start, exitpattern;
int count, iLevel, magic, i;
tf_triangle tri;
triangle_t *ptri;
t = -FLOAT_START;
*((unsigned char *) &exitpattern + 0) = *((unsigned char *) &t + 3);
*((unsigned char *) &exitpattern + 1) = *((unsigned char *) &t + 2);
*((unsigned char *) &exitpattern + 2) = *((unsigned char *) &t + 1);
*((unsigned char *) &exitpattern + 3) = *((unsigned char *) &t + 0);
// FIXME not sure if this should be BigFloat or FloatSwap
exitpattern = BigFloat (FLOAT_END);
//*((unsigned char *) &exitpattern + 0) = *((unsigned char *) &t + 3);
//*((unsigned char *) &exitpattern + 1) = *((unsigned char *) &t + 2);
//*((unsigned char *) &exitpattern + 2) = *((unsigned char *) &t + 1);
//*((unsigned char *) &exitpattern + 3) = *((unsigned char *) &t + 0);
if ((input = Qopen(filename, "rb")) == 0) {
fprintf (stderr,"reader: could not open file '%s'\n", filename);