From 264666d8dd5ef7eec1acaafb211d7516e2eadae1 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 10 Jun 2022 13:24:09 +1000 Subject: [PATCH] Fix GCC 11 warns: Matrix4x4_FromArrayDoubleD3D overread Signed-off-by: bones_was_here --- matrixlib.c | 66 +++++++++++++++++++++++++-------------------------- matrixlib.h | 2 +- model_brush.c | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/matrixlib.c b/matrixlib.c index dd6f3c6a..2724ce6a 100644 --- a/matrixlib.c +++ b/matrixlib.c @@ -1123,42 +1123,42 @@ void Matrix4x4_ToArrayDoubleD3D(const matrix4x4_t *in, double out[16]) #endif } -void Matrix4x4_FromArrayDoubleD3D (matrix4x4_t *out, const double in[16]) +void Matrix4x4_FromArrayDoubleD3D (matrix4x4_t *out, const double in[4][4]) { #ifdef MATRIX4x4_OPENGLORIENTATION - out->m[0][0] = in[0]; - out->m[1][0] = in[1]; - out->m[2][0] = in[2]; - out->m[3][0] = in[3]; - out->m[0][1] = in[4]; - out->m[1][1] = in[5]; - out->m[2][1] = in[6]; - out->m[3][1] = in[7]; - out->m[0][2] = in[8]; - out->m[1][2] = in[9]; - out->m[2][2] = in[10]; - out->m[3][2] = in[11]; - out->m[0][3] = in[12]; - out->m[1][3] = in[13]; - out->m[2][3] = in[14]; - out->m[3][3] = in[15]; + out->m[0][0] = in[0][0]; + out->m[1][0] = in[0][1]; + out->m[2][0] = in[0][2]; + out->m[3][0] = in[0][3]; + out->m[0][1] = in[1][0]; + out->m[1][1] = in[1][1]; + out->m[2][1] = in[1][2]; + out->m[3][1] = in[1][3]; + out->m[0][2] = in[2][0]; + out->m[1][2] = in[2][1]; + out->m[2][2] = in[2][2]; + out->m[3][2] = in[2][3]; + out->m[0][3] = in[3][0]; + out->m[1][3] = in[3][1]; + out->m[2][3] = in[3][2]; + out->m[3][3] = in[3][3]; #else - out->m[0][0] = in[0]; - out->m[0][1] = in[1]; - out->m[0][2] = in[2]; - out->m[0][3] = in[3]; - out->m[1][0] = in[4]; - out->m[1][1] = in[5]; - out->m[1][2] = in[6]; - out->m[1][3] = in[7]; - out->m[2][0] = in[8]; - out->m[2][1] = in[9]; - out->m[2][2] = in[10]; - out->m[2][3] = in[11]; - out->m[3][0] = in[12]; - out->m[3][1] = in[13]; - out->m[3][2] = in[14]; - out->m[3][3] = in[15]; + out->m[0][0] = in[0][0]; + out->m[0][1] = in[0][1]; + out->m[0][2] = in[0][2]; + out->m[0][3] = in[0][3]; + out->m[1][0] = in[1][0]; + out->m[1][1] = in[1][1]; + out->m[1][2] = in[1][2]; + out->m[1][3] = in[1][3]; + out->m[2][0] = in[2][0]; + out->m[2][1] = in[2][1]; + out->m[2][2] = in[2][2]; + out->m[2][3] = in[2][3]; + out->m[3][0] = in[3][0]; + out->m[3][1] = in[3][1]; + out->m[3][2] = in[3][2]; + out->m[3][3] = in[3][3]; #endif } diff --git a/matrixlib.h b/matrixlib.h index cf762524..f2e60e28 100644 --- a/matrixlib.h +++ b/matrixlib.h @@ -93,7 +93,7 @@ void Matrix4x4_FromArrayDoubleGL(matrix4x4_t *out, const double in[16]); // converts a matrix4x4 to a double[16] array in the Direct3D orientation void Matrix4x4_ToArrayDoubleD3D(const matrix4x4_t *in, double out[16]); // creates a matrix4x4 from a double[16] array in the Direct3D orientation -void Matrix4x4_FromArrayDoubleD3D(matrix4x4_t *out, const double in[16]); +void Matrix4x4_FromArrayDoubleD3D(matrix4x4_t *out, const double in[4][4]); // converts a matrix4x4 to a float[16] array in the OpenGL orientation void Matrix4x4_ToArrayFloatGL(const matrix4x4_t *in, float out[16]); diff --git a/model_brush.c b/model_brush.c index 82eca27c..9b97b801 100644 --- a/model_brush.c +++ b/model_brush.c @@ -6563,7 +6563,7 @@ static void Mod_Q3BSP_LoadLightGrid(lump_t *l) lightgridmatrix[1][3] = -(loadmodel->brushq3.num_lightgrid_imins[1] - 0.5f) / texturesize[1]; lightgridmatrix[2][3] = -(loadmodel->brushq3.num_lightgrid_imins[2] - 1.5f) / texturesize[2]; lightgridmatrix[3][3] = 1; - Matrix4x4_FromArrayDoubleD3D(&loadmodel->brushq3.lightgridworldtotexturematrix, lightgridmatrix[0]); + Matrix4x4_FromArrayDoubleD3D(&loadmodel->brushq3.lightgridworldtotexturematrix, lightgridmatrix); loadmodel->brushq3.lightgridtexture = R_LoadTexture3D(loadmodel->texturepool, "lightgrid", texturesize[0], texturesize[1], texturesize[2], texturergba, TEXTYPE_RGBA, TEXF_CLAMP, 0, NULL); Mem_Free(texturergba); } -- 2.39.2