Fix -Wuninitialized warnings

may be used uninitialized in this function
This commit is contained in:
dhewg 2011-12-02 23:39:30 +01:00
parent ee0996e380
commit 09f3aa0568
28 changed files with 99 additions and 45 deletions

View file

@ -2025,8 +2025,8 @@ idCollisionModelManagerLocal::R_CreateAxialBSPTree
================
*/
cm_node_t *idCollisionModelManagerLocal::R_CreateAxialBSPTree( cm_model_t *model, cm_node_t *node, const idBounds &bounds ) {
int planeType;
float planeDist;
int planeType = 0;
float planeDist = 0.0f;
cm_polygonRef_t *pref, *nextpref, *prevpref;
cm_brushRef_t *bref, *nextbref, *prevbref;
cm_node_t *frontNode, *backNode, *n;

View file

@ -3215,7 +3215,7 @@ void idHarvestable::Init(idEntity* parent) {
parent->SetSkin(declManager->FindSkin(skin.c_str()));
}
idEntity* head;
idEntity* head = NULL;
if(parent->IsType(idActor::Type)) {
idActor* withHead = (idActor*)parent;
head = withHead->GetHeadEntity();
@ -3358,7 +3358,7 @@ void idHarvestable::BeginBurn() {
parent->GetRenderEntity()->noShadow = true;
parent->SetShaderParm( SHADERPARM_TIME_OF_DEATH, gameLocal.slow.time * 0.001f );
idEntity* head;
idEntity* head = NULL;
if(parent->IsType(idActor::Type)) {
idActor* withHead = (idActor*)parent;
head = withHead->GetHeadEntity();

View file

@ -561,10 +561,12 @@ public:
ID_INLINE SetTimeState::SetTimeState() {
activated = false;
previousFast = false;
}
ID_INLINE SetTimeState::SetTimeState( int timeGroup ) {
activated = false;
previousFast = false;
PushState( timeGroup );
}

View file

@ -561,7 +561,7 @@ idIK_Walk::Evaluate
================
*/
void idIK_Walk::Evaluate( void ) {
int i, newPivotFoot;
int i, newPivotFoot = 0;
float modelHeight, jointHeight, lowestHeight, floorHeights[MAX_LEGS];
float shift, smallestShift, newHeight, step, newPivotYaw, height, largestAnkleHeight;
idVec3 modelOrigin, normal, hipDir, kneeDir, start, end, jointOrigins[MAX_LEGS];

View file

@ -251,7 +251,7 @@ bool idSmokeParticles::EmitSmoke( const idDeclParticle *smoke, const int systemS
}
// find an activeSmokeStage that matches this
activeSmokeStage_t *active;
activeSmokeStage_t *active = NULL;
int i;
for ( i = 0 ; i < activeStages.Num() ; i++ ) {
active = &activeStages[i];

View file

@ -185,6 +185,9 @@ void GetPointOutsideObstacles( const obstacle_t *obstacles, const int numObstacl
}
}
if (i == 0)
return;
newPoint = point - ( bestd + PUSH_OUTSIDE_OBSTACLES ) * bestPlane.ToVec2();
if ( PointInsideObstacle( obstacles, numObstacles, newPoint ) == -1 ) {
point = newPoint;
@ -423,6 +426,7 @@ int GetObstacles( const idPhysics *physics, const idAAS *aas, const idEntity *ig
lastVerts[0] = lastVerts[1] = 0;
lastEdgeNormal.Zero();
nextEdgeNormal.Zero();
nextVerts[0] = nextVerts[1] = 0;
for ( i = 0; i < numWallEdges && numObstacles < MAX_OBSTACLES; i++ ) {
aas->GetEdge( wallEdges[i], start, end );

View file

@ -161,6 +161,8 @@ void idForce_Field::Evaluate( int time ) {
bounds.FromTransformedBounds( clipModel->GetBounds(), clipModel->GetOrigin(), clipModel->GetAxis() );
numClipModels = gameLocal.clip.ClipModelsTouchingBounds( bounds, -1, clipModelList, MAX_GENTITIES );
torque.Zero();
for ( i = 0; i < numClipModels; i++ ) {
cm = clipModelList[ i ];
@ -208,7 +210,7 @@ void idForce_Field::Evaluate( int time ) {
}
default: {
gameLocal.Error( "idForce_Field: invalid type" );
break;
return;
}
}
@ -250,7 +252,7 @@ void idForce_Field::Evaluate( int time ) {
}
default: {
gameLocal.Error( "idForce_Field: invalid apply type" );
break;
return;
}
}
}

View file

@ -633,6 +633,7 @@ void idAFConstraint_BallAndSocketJoint::Evaluate( float invTimeStep ) {
c1.SubVec3(0) = -( invTimeStep * ERROR_REDUCTION ) * ( a2 + master->GetWorldOrigin() - ( a1 + body1->GetWorldOrigin() ) );
}
else {
a2.Zero();
c1.SubVec3(0) = -( invTimeStep * ERROR_REDUCTION ) * ( anchor2 - ( a1 + body1->GetWorldOrigin() ) );
}
@ -4481,7 +4482,7 @@ idAFTree::Factor
void idAFTree::Factor( void ) const {
int i, j;
idAFBody *body;
idAFConstraint *child;
idAFConstraint *child = NULL;
idMatX childI;
childI.SetData( 6, 6, MATX_ALLOCA( 6 * 6 ) );

View file

@ -937,6 +937,9 @@ void idParticleStage::ParticleOrigin( particleGen_t *g, idVec3 &origin ) const {
dir.Normalize();
dir[2] += directionParms[0];
break;
default:
common->Error( "idParticleStage::ParticleOrigin: bad direction" );
return;
}
}
@ -1044,6 +1047,8 @@ int idParticleStage::ParticleVerts( particleGen_t *g, idVec3 origin, idDrawVert
int numTrails = idMath::Ftoi( orientationParms[0] );
float trailTime = orientationParms[1];
stepLeft.Zero();
if ( trailTime == 0 ) {
trailTime = 0.5f;
}

View file

@ -561,7 +561,7 @@ idIK_Walk::Evaluate
================
*/
void idIK_Walk::Evaluate( void ) {
int i, newPivotFoot;
int i, newPivotFoot = 0;
float modelHeight, jointHeight, lowestHeight, floorHeights[MAX_LEGS];
float shift, smallestShift, newHeight, step, newPivotYaw, height, largestAnkleHeight;
idVec3 modelOrigin, normal, hipDir, kneeDir, start, end, jointOrigins[MAX_LEGS];

View file

@ -237,7 +237,7 @@ bool idSmokeParticles::EmitSmoke( const idDeclParticle *smoke, const int systemS
}
// find an activeSmokeStage that matches this
activeSmokeStage_t *active;
activeSmokeStage_t *active = NULL;
int i;
for ( i = 0 ; i < activeStages.Num() ; i++ ) {
active = &activeStages[i];

View file

@ -185,6 +185,9 @@ void GetPointOutsideObstacles( const obstacle_t *obstacles, const int numObstacl
}
}
if (i == 0)
return;
newPoint = point - ( bestd + PUSH_OUTSIDE_OBSTACLES ) * bestPlane.ToVec2();
if ( PointInsideObstacle( obstacles, numObstacles, newPoint ) == -1 ) {
point = newPoint;
@ -423,6 +426,7 @@ int GetObstacles( const idPhysics *physics, const idAAS *aas, const idEntity *ig
lastVerts[0] = lastVerts[1] = 0;
lastEdgeNormal.Zero();
nextEdgeNormal.Zero();
nextVerts[0] = nextVerts[1] = 0;
for ( i = 0; i < numWallEdges && numObstacles < MAX_OBSTACLES; i++ ) {
aas->GetEdge( wallEdges[i], start, end );

View file

@ -161,6 +161,8 @@ void idForce_Field::Evaluate( int time ) {
bounds.FromTransformedBounds( clipModel->GetBounds(), clipModel->GetOrigin(), clipModel->GetAxis() );
numClipModels = gameLocal.clip.ClipModelsTouchingBounds( bounds, -1, clipModelList, MAX_GENTITIES );
torque.Zero();
for ( i = 0; i < numClipModels; i++ ) {
cm = clipModelList[ i ];
@ -208,7 +210,7 @@ void idForce_Field::Evaluate( int time ) {
}
default: {
gameLocal.Error( "idForce_Field: invalid type" );
break;
return;
}
}
@ -250,7 +252,7 @@ void idForce_Field::Evaluate( int time ) {
}
default: {
gameLocal.Error( "idForce_Field: invalid apply type" );
break;
return;
}
}
}

View file

@ -633,6 +633,7 @@ void idAFConstraint_BallAndSocketJoint::Evaluate( float invTimeStep ) {
c1.SubVec3(0) = -( invTimeStep * ERROR_REDUCTION ) * ( a2 + master->GetWorldOrigin() - ( a1 + body1->GetWorldOrigin() ) );
}
else {
a2.Zero();
c1.SubVec3(0) = -( invTimeStep * ERROR_REDUCTION ) * ( anchor2 - ( a1 + body1->GetWorldOrigin() ) );
}
@ -4480,7 +4481,7 @@ idAFTree::Factor
void idAFTree::Factor( void ) const {
int i, j;
idAFBody *body;
idAFConstraint *child;
idAFConstraint *child = NULL;
idMatX childI;
childI.SetData( 6, 6, MATX_ALLOCA( 6 * 6 ) );

View file

@ -680,7 +680,8 @@ bool idSurface::IsPolytope( const float epsilon ) const {
}
for ( i = 0; i < indexes.Num(); i += 3 ) {
plane.FromPoints( verts[indexes[i+0]].xyz, verts[indexes[i+1]].xyz, verts[indexes[i+2]].xyz );
if (!plane.FromPoints( verts[indexes[i+0]].xyz, verts[indexes[i+1]].xyz, verts[indexes[i+2]].xyz ))
return false;
for ( j = 0; j < verts.Num(); j++ ) {
if ( plane.Side( verts[j].xyz, epsilon ) == SIDE_FRONT ) {
@ -784,7 +785,7 @@ idSurface::RayIntersection
*/
bool idSurface::RayIntersection( const idVec3 &start, const idVec3 &dir, float &scale, bool backFaceCull ) const {
int i, i0, i1, i2, s0, s1, s2;
float d, s;
float d, s = 0.0f;
byte *sidedness;
idPluecker rayPl, pl;
idPlane plane;
@ -811,13 +812,15 @@ bool idSurface::RayIntersection( const idVec3 &start, const idVec3 &dir, float &
s2 = sidedness[abs(i2)] ^ INTSIGNBITSET( i2 );
if ( s0 & s1 & s2 ) {
plane.FromPoints( verts[indexes[i+0]].xyz, verts[indexes[i+1]].xyz, verts[indexes[i+2]].xyz );
if (!plane.FromPoints( verts[indexes[i+0]].xyz, verts[indexes[i+1]].xyz, verts[indexes[i+2]].xyz ))
return false;
plane.RayIntersection( start, dir, s );
if ( idMath::Fabs( s ) < idMath::Fabs( scale ) ) {
scale = s;
}
} else if ( !backFaceCull && !(s0 | s1 | s2) ) {
plane.FromPoints( verts[indexes[i+0]].xyz, verts[indexes[i+1]].xyz, verts[indexes[i+2]].xyz );
if (!plane.FromPoints( verts[indexes[i+0]].xyz, verts[indexes[i+1]].xyz, verts[indexes[i+2]].xyz ))
return false;
plane.RayIntersection( start, dir, s );
if ( idMath::Fabs( s ) < idMath::Fabs( scale ) ) {
scale = s;

View file

@ -638,6 +638,9 @@ static void getCubeVector(int i, int cubesize, int x, int y, float *vector) {
vector[1] = -tc;
vector[2] = -1.0;
break;
default:
common->Error ("getCubeVector: invalid cube map face index");
return;
}
mag = idMath::InvSqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]);
@ -652,7 +655,7 @@ static void getCubeVector(int i, int cubesize, int x, int y, float *vector) {
* access the cube map.
*/
static void makeNormalizeVectorCubeMap( idImage *image ) {
float vector[3];
float vector[3] = { };
int i, x, y;
byte *pixels[6];
int size;

View file

@ -354,7 +354,8 @@ void idRenderModelDecal::CreateDecal( const idRenderModel *model, const decalPro
fw[j] = stri->verts[stri->indexes[index+j]].xyz;
dir = fw[j].ToVec3() - localInfo.projectionOrigin;
localInfo.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 1].RayIntersection( fw[j].ToVec3(), dir, scale );
if (!localInfo.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 1].RayIntersection( fw[j].ToVec3(), dir, scale ))
scale = 0.0f;
dir = fw[j].ToVec3() + scale * dir;
fw[j].s = localInfo.textureAxis[0].Distance( dir );
fw[j].t = localInfo.textureAxis[1].Distance( dir );

View file

@ -338,7 +338,7 @@ Read an ENVL chunk from an LWO2 file.
lwEnvelope *lwGetEnvelope( idFile *fp, int cksize )
{
lwEnvelope *env;
lwKey *key;
lwKey *key = NULL;
lwPlugin *plug;
unsigned int id;
unsigned short sz;
@ -1821,8 +1821,8 @@ Read an lwSurface from an LWOB file.
lwSurface *lwGetSurface5( idFile *fp, int cksize, lwObject *obj )
{
lwSurface *surf;
lwTexture *tex;
lwPlugin *shdr;
lwTexture *tex = NULL;
lwPlugin *shdr = NULL;
char *s;
float v[ 3 ];
unsigned int id, flags;
@ -1987,7 +1987,7 @@ lwSurface *lwGetSurface5( idFile *fp, int cksize, lwObject *obj )
case ID_TFLG:
flags = getU2( fp );
if ( flags & 1 ) i = 0;
i = 0;
if ( flags & 2 ) i = 1;
if ( flags & 4 ) i = 2;
tex->axis = i;
@ -2079,6 +2079,7 @@ lwSurface *lwGetSurface5( idFile *fp, int cksize, lwObject *obj )
break;
case ID_SDAT:
if ( !shdr ) goto Fail;
shdr->data = getbytes( fp, sz );
break;

View file

@ -330,7 +330,7 @@ void idRenderWorldLocal::FloodLightThroughArea_r( idRenderLightLocal *light, int
portal_t* p;
float d;
portalArea_t * area;
const portalStack_t *check, *firstPortalStack;
const portalStack_t *check, *firstPortalStack = NULL;
portalStack_t newStack;
int i, j;
idVec3 v1, v2;

View file

@ -368,7 +368,7 @@ void R_LoadARBProgram( int progIndex ) {
fullPath += progs[progIndex].name;
char *fileBuffer;
char *buffer;
char *start, *end;
char *start = NULL, *end;
common->Printf( "%s", fullPath.c_str() );
@ -405,14 +405,14 @@ void R_LoadARBProgram( int progIndex ) {
common->Printf( ": GL_VERTEX_PROGRAM_ARB not available\n" );
return;
}
start = strstr( (char *)buffer, "!!ARBvp" );
start = strstr( buffer, "!!ARBvp" );
}
if ( progs[progIndex].target == GL_FRAGMENT_PROGRAM_ARB ) {
if ( !glConfig.ARBFragmentProgramAvailable ) {
common->Printf( ": GL_FRAGMENT_PROGRAM_ARB not available\n" );
return;
}
start = strstr( (char *)buffer, "!!ARBfp" );
start = strstr( buffer, "!!ARBfp" );
}
if ( !start ) {
common->Printf( ": !!ARB not found\n" );
@ -430,7 +430,7 @@ void R_LoadARBProgram( int progIndex ) {
qglGetError();
qglProgramStringARB( progs[progIndex].target, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen( start ), (unsigned char *)start );
strlen( start ), start );
err = qglGetError();
qglGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, (GLint *)&ofs );
@ -439,7 +439,7 @@ void R_LoadARBProgram( int progIndex ) {
common->Printf( "\nGL_PROGRAM_ERROR_STRING_ARB: %s\n", str );
if ( ofs < 0 ) {
common->Printf( "GL_PROGRAM_ERROR_POSITION_ARB < 0 with error\n" );
} else if ( ofs >= (int)strlen( (char *)start ) ) {
} else if ( ofs >= (int)strlen( start ) ) {
common->Printf( "error at end of program\n" );
} else {
common->Printf( "error at %i:\n%s", ofs, start + ofs );

View file

@ -532,7 +532,10 @@ static void R_FlareDeform( drawSurf_t *surf ) {
idDrawVert *ac = (idDrawVert *)_alloca16( newTri->numVerts * sizeof( idDrawVert ) );
// find the plane
plane.FromPoints( tri->verts[tri->indexes[0]].xyz, tri->verts[tri->indexes[1]].xyz, tri->verts[tri->indexes[2]].xyz );
if (!plane.FromPoints( tri->verts[tri->indexes[0]].xyz, tri->verts[tri->indexes[1]].xyz, tri->verts[tri->indexes[2]].xyz )) {
common->Warning( "R_FlareDeform: plane.FromPoints failed" );
return;
}
// if viewer is behind the plane, draw nothing
R_GlobalPointToLocal( surf->space->modelMatrix, tr.viewDef->renderView.vieworg, localViewer );

View file

@ -1248,8 +1248,8 @@ void R_AddDrawSurf( const srfTriangles_t *tri, const viewEntity_t *space, const
shaderParms = renderEntity->shaderParms;
}
float oldFloatTime;
int oldTime;
float oldFloatTime = 0.0f;
int oldTime = 0;
if ( space->entityDef && space->entityDef->parms.timeGroup ) {
oldFloatTime = tr.viewDef->floatTime;
@ -1481,8 +1481,8 @@ void R_AddModelSurfaces( void ) {
}
}
float oldFloatTime;
int oldTime;
float oldFloatTime = 0.0f;
int oldTime = 0;
game->SelectTimeGroup( vEntity->entityDef->parms.timeGroup );

View file

@ -1760,7 +1760,7 @@ RB_DrawText
*/
static void RB_DrawText( const char *text, const idVec3 &origin, float scale, const idVec4 &color, const idMat3 &viewAxis, const int align ) {
int i, j, len, num, index, charIndex, line;
float textLen, spacing;
float textLen = 0.0f, spacing;
idVec3 org, p1, p2;
if ( text && *text ) {
@ -1773,6 +1773,7 @@ static void RB_DrawText( const char *text, const idVec3 &origin, float scale, co
line = 0;
}
org.Zero();
len = strlen( text );
for ( i = 0; i < len; i++ ) {

View file

@ -329,6 +329,15 @@ bool idAASReach::Reachability_Step_Barrier_WaterJump_WalkOffLedge( int area1num,
}
}
floor_bestArea1FloorEdgeNum = 0;
floor_bestStart.Zero();
floor_bestEnd.Zero();
floor_bestNormal.Zero();
water_bestStart.Zero();
water_bestEnd.Zero();
water_bestNormal.Zero();
floor_foundReach = false;
floor_bestDist = 99999;
floor_bestLength = 0;

View file

@ -1116,7 +1116,7 @@ idBrushBSP::MakeNodePortal
void idBrushBSP::MakeNodePortal( idBrushBSPNode *node ) {
idBrushBSPPortal *newPortal, *p;
idWinding *w;
int side;
int side = 0;
w = BaseWindingForNode( node );
@ -1179,6 +1179,7 @@ void idBrushBSP::SplitNodePortals( idBrushBSPNode *node ) {
}
else {
common->Error( "idBrushBSP::SplitNodePortals: mislinked portal" );
return;
}
nextPortal = p->next[side];
@ -1363,8 +1364,8 @@ void idBrushBSP::LeakFile( const idStr &fileName ) {
int count, next, s;
idVec3 mid;
idFile *lineFile;
idBrushBSPNode *node, *nextNode;
idBrushBSPPortal *p, *nextPortal;
idBrushBSPNode *node, *nextNode = NULL;
idBrushBSPPortal *p, *nextPortal = NULL;
idStr qpath, name;
if ( !outside->occupied ) {

View file

@ -79,8 +79,8 @@ void LeakFile (tree_t *tree)
while (node->occupied > 1)
{
int next;
uPortal_t *p, *nextportal;
node_t *nextnode;
uPortal_t *p, *nextportal = NULL;
node_t *nextnode = NULL;
int s;
// find the best portal exit

View file

@ -632,6 +632,7 @@ static void RemoveIfColinear( optVertex_t *ov, optIsland_t *island ) {
e = e->v2link;
} else {
common->Error( "RemoveIfColinear: mislinked edge" );
return;
}
}
@ -653,6 +654,7 @@ static void RemoveIfColinear( optVertex_t *ov, optIsland_t *island ) {
v1 = e1->v1;
} else {
common->Error( "RemoveIfColinear: mislinked edge" );
return;
}
if ( e2->v1 == v2 ) {
v3 = e2->v2;
@ -660,10 +662,12 @@ static void RemoveIfColinear( optVertex_t *ov, optIsland_t *island ) {
v3 = e2->v1;
} else {
common->Error( "RemoveIfColinear: mislinked edge" );
return;
}
if ( v1 == v3 ) {
common->Error( "RemoveIfColinear: mislinked edge" );
return;
}
// they must point in opposite directions
@ -707,6 +711,7 @@ static void RemoveIfColinear( optVertex_t *ov, optIsland_t *island ) {
// v2 should have no edges now
if ( v2->edges ) {
common->Error( "RemoveIfColinear: didn't remove properly" );
return;
}
@ -942,6 +947,7 @@ static void CreateOptTri( optVertex_t *first, optEdge_t *e1, optEdge_t *e2, optI
second = e1->v1;
} else {
common->Error( "CreateOptTri: mislinked edge" );
return;
}
if ( e2->v1 == first ) {
@ -950,10 +956,12 @@ static void CreateOptTri( optVertex_t *first, optEdge_t *e1, optEdge_t *e2, optI
third = e2->v1;
} else {
common->Error( "CreateOptTri: mislinked edge" );
return;
}
if ( !IsTriangleValid( first, second, third ) ) {
common->Error( "CreateOptTri: invalid" );
return;
}
//DrawEdges( island );
@ -984,6 +992,7 @@ static void CreateOptTri( optVertex_t *first, optEdge_t *e1, optEdge_t *e2, optI
opposite = opposite->v2link;
} else {
common->Error( "BuildOptTriangles: mislinked edge" );
return;
}
}
@ -1088,8 +1097,8 @@ Generate a new list of triangles from the optEdeges
====================
*/
static void BuildOptTriangles( optIsland_t *island ) {
optVertex_t *ov, *second, *third, *middle;
optEdge_t *e1, *e1Next, *e2, *e2Next, *check, *checkNext;
optVertex_t *ov, *second = NULL, *third = NULL, *middle = NULL;
optEdge_t *e1, *e1Next = NULL, *e2, *e2Next = NULL, *check, *checkNext = NULL;
// free them
FreeOptTriangles( island );

View file

@ -1168,7 +1168,7 @@ void RenderBump_f( const idCmdArgs &args ) {
int i, j;
const char *cmdLine;
int numRenderBumps;
renderBump_t *renderBumps, *rb;
renderBump_t *renderBumps, *rb = NULL;
renderBump_t opt;
int startTime, endTime;
@ -1381,6 +1381,7 @@ void RenderBumpFlat_f( const idCmdArgs &args ) {
if ( i != ( args.Argc() - 1 ) ) {
common->Error( "usage: renderBumpFlat [-size width height] asefile" );
return;
}
common->Printf( "Final image size: %i, %i\n", width, height );
@ -1547,6 +1548,8 @@ void RenderBumpFlat_f( const idCmdArgs &args ) {
GLimp_SwapBuffers();
qglReadPixels( 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
c = width * height;
if ( colorPass ) {
// add to the sum buffer
for ( i = 0 ; i < c ; i++ ) {
@ -1557,7 +1560,6 @@ void RenderBumpFlat_f( const idCmdArgs &args ) {
}
} else {
// normalize
c = width * height;
for ( i = 0 ; i < c ; i++ ) {
idVec3 v;