mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-24 11:31:59 +00:00
Fix GCC -W(maybe-)uninitialized warnings that at least kinda had a point
This commit is contained in:
parent
5844af62ce
commit
957176d659
7 changed files with 47 additions and 9 deletions
|
@ -224,6 +224,7 @@ idSurface_Patch::LerpVert
|
|||
============
|
||||
*/
|
||||
void idSurface_Patch::LerpVert( const idDrawVert &a, const idDrawVert &b, idDrawVert &out ) const {
|
||||
// DG: TODO: what about out.tangent and out.color ?
|
||||
out.xyz[0] = 0.5f * ( a.xyz[0] + b.xyz[0] );
|
||||
out.xyz[1] = 0.5f * ( a.xyz[1] + b.xyz[1] );
|
||||
out.xyz[2] = 0.5f * ( a.xyz[2] + b.xyz[2] );
|
||||
|
@ -554,7 +555,11 @@ idSurface_Patch::Subdivide
|
|||
*/
|
||||
void idSurface_Patch::Subdivide( float maxHorizontalError, float maxVerticalError, float maxLength, bool genNormals ) {
|
||||
int i, j, k, l;
|
||||
idDrawVert prev, next, mid;
|
||||
// DG: to shut up GCC (maybe-)uninitialized warnings, initialize prev, next and mid
|
||||
// (maybe the warnings were at least partly correct, because .tangent and .color aren't set by idSurface_Patch::LerpVert())
|
||||
idDrawVert prev;
|
||||
prev.Clear();
|
||||
idDrawVert next = prev, mid = prev;
|
||||
idVec3 prevxyz, nextxyz, midxyz;
|
||||
idVec3 delta;
|
||||
float maxHorizontalErrorSqr, maxVerticalErrorSqr, maxLengthSqr;
|
||||
|
|
|
@ -102,7 +102,12 @@ int idWinding::Split( const idPlane &plane, const float epsilon, idWinding **fro
|
|||
idWinding * f, *b;
|
||||
int maxpts;
|
||||
|
||||
assert( this );
|
||||
assert( this && numPoints > 0);
|
||||
|
||||
// DG: unlikely, but makes sure we don't use uninitialized memory below
|
||||
if ( numPoints == 0 ) {
|
||||
return 0; // it's not like the callers check the return value anyway..
|
||||
}
|
||||
|
||||
dists = (float *) _alloca( (numPoints+4) * sizeof( float ) );
|
||||
sides = (byte *) _alloca( (numPoints+4) * sizeof( byte ) );
|
||||
|
@ -245,7 +250,13 @@ idWinding *idWinding::Clip( const idPlane &plane, const float epsilon, const boo
|
|||
idVec5 mid;
|
||||
int maxpts;
|
||||
|
||||
assert( this );
|
||||
assert( this && numPoints > 0 );
|
||||
|
||||
// DG: this shouldn't happen, probably, but if it does we'd use uninitialized memory below
|
||||
if ( numPoints == 0 ) {
|
||||
delete this;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dists = (float *) _alloca( (numPoints+4) * sizeof( float ) );
|
||||
sides = (byte *) _alloca( (numPoints+4) * sizeof( byte ) );
|
||||
|
|
|
@ -92,6 +92,12 @@ void idWinding2D::ExpandForAxialBox( const idVec2 bounds[2] ) {
|
|||
assert( numPlanes < MAX_POINTS_ON_WINDING_2D );
|
||||
planes[numPlanes++] = plane;
|
||||
}
|
||||
|
||||
// DG: make sure planes[] isn't used uninitialized and with index -1 below
|
||||
if ( numPlanes == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( GetAxialBevel( planes[numPlanes-1], planes[0], p[0], bevel ) ) {
|
||||
planes[numPlanes++] = bevel;
|
||||
}
|
||||
|
@ -259,6 +265,11 @@ bool idWinding2D::ClipInPlace( const idVec3 &plane, const float epsilon, const b
|
|||
float dot, dists[MAX_POINTS_ON_WINDING_2D+1];
|
||||
idVec2 *p1, *p2, mid, newPoints[MAX_POINTS_ON_WINDING_2D+4];
|
||||
|
||||
// DG: avoid all kinds of unitialized usages below
|
||||
if ( numPoints == 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
counts[SIDE_FRONT] = counts[SIDE_BACK] = counts[SIDE_ON] = 0;
|
||||
|
||||
for ( i = 0; i < numPoints; i++ ) {
|
||||
|
|
|
@ -456,6 +456,14 @@ void VPCALL idSIMD_SSE::Dot( float *dst, const idVec3 &constant, const idPlane *
|
|||
char *dst_p;
|
||||
__m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
|
||||
|
||||
// DG: GCC and clang warn about xmm1-4 maybe being used uninitialized below.
|
||||
// according to https://stackoverflow.com/a/18749079 the initialization
|
||||
// code is generated anyway, so make it explicit to shut up the warning
|
||||
xmm1 = _mm_setzero_ps();
|
||||
xmm2 = _mm_setzero_ps();
|
||||
xmm3 = _mm_setzero_ps();
|
||||
xmm4 = _mm_setzero_ps();
|
||||
|
||||
/*
|
||||
mov eax, count
|
||||
mov edi, constant
|
||||
|
|
|
@ -4642,7 +4642,9 @@ static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
|
|||
|
||||
static int get_seek_page_info(stb_vorbis *f, ProbedPage *z)
|
||||
{
|
||||
uint8 header[27], lacing[255];
|
||||
// DG: zero out the header, it could be uninitialized if getn() fails
|
||||
// and then the check for "OggS" is unreliable
|
||||
uint8 header[27] = {0}, lacing[255];
|
||||
int i,len;
|
||||
|
||||
// record where the page starts
|
||||
|
|
|
@ -68,6 +68,7 @@ idLedge::idLedge( const idVec3 &v1, const idVec3 &v2, const idVec3 &gravityDir,
|
|||
planes[3].SetNormal( v2 - v1 );
|
||||
planes[3].Normalize();
|
||||
planes[3].FitThroughPoint( v2 );
|
||||
numExpandedPlanes = numSplitPlanes = 0; // DG: make sure those are initialized
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -60,15 +60,15 @@ int idDeviceContext::FindFont( const char *name ) {
|
|||
idStr fileName = name;
|
||||
fileName.Replace("fonts", va("fonts/%s", fontLang.c_str()) );
|
||||
|
||||
fontInfoEx_t fontInfo;
|
||||
int index = fonts.Append( fontInfo );
|
||||
if ( renderSystem->RegisterFont( fileName, fonts[index] ) ){
|
||||
fontInfoEx_t fontInfo = {}; // DG: initialize this
|
||||
int index = fonts.Append( fontInfo );
|
||||
if ( renderSystem->RegisterFont( fileName, fonts[index] ) ){
|
||||
idStr::Copynz( fonts[index].name, name, sizeof( fonts[index].name ) );
|
||||
return index;
|
||||
} else {
|
||||
} else {
|
||||
common->Printf( "Could not register font %s [%s]\n", name, fileName.c_str() );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void idDeviceContext::SetupFonts() {
|
||||
|
|
Loading…
Reference in a new issue