From ecf45acd236aaf1a0d2b00a94a24d8f24fbceae4 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 26 Mar 2013 16:50:03 +0000 Subject: Fix some of the things clang --analyze flagged --- src/renderergl2/tr_backend.c | 14 ++++++-------- src/renderergl2/tr_bsp.c | 3 --- src/renderergl2/tr_image.c | 8 +++----- src/renderergl2/tr_main.c | 4 ---- src/renderergl2/tr_marks.c | 4 ++-- src/renderergl2/tr_shader.c | 3 +-- src/renderergl2/tr_world.c | 2 +- 7 files changed, 13 insertions(+), 25 deletions(-) (limited to 'src/renderergl2') diff --git a/src/renderergl2/tr_backend.c b/src/renderergl2/tr_backend.c index 6d6b0274..6b541fec 100644 --- a/src/renderergl2/tr_backend.c +++ b/src/renderergl2/tr_backend.c @@ -54,7 +54,9 @@ void GL_Bind2( image_t *image, GLenum type ) { } if ( glState.currenttextures[glState.currenttmu] != texnum ) { - image->frameUsed = tr.frameCount; + if ( image ) { + image->frameUsed = tr.frameCount; + } glState.currenttextures[glState.currenttmu] = texnum; qglBindTexture (type, texnum); } @@ -252,7 +254,7 @@ void GL_State( unsigned long stateBits ) // if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) { - GLenum srcFactor, dstFactor; + GLenum srcFactor = GL_ONE, dstFactor = GL_ONE; if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) { @@ -286,7 +288,6 @@ void GL_State( unsigned long stateBits ) srcFactor = GL_SRC_ALPHA_SATURATE; break; default: - srcFactor = GL_ONE; // to get warning to shut up ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); break; } @@ -318,7 +319,6 @@ void GL_State( unsigned long stateBits ) dstFactor = GL_ONE_MINUS_DST_ALPHA; break; default: - dstFactor = GL_ONE; // to get warning to shut up ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); break; } @@ -608,7 +608,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { oldDlighted = qfalse; oldPshadowed = qfalse; oldSort = -1; - depthRange = qfalse; depth[0] = 0.f; depth[1] = 1.f; @@ -631,8 +630,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // change the tess parameters if needed // a "entityMergable" shader is a shader that can have surfaces from seperate // entities merged into a single batch, like smoke and blood puff sprites - if (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed - || ( entityNum != oldEntityNum && !shader->entityMergable ) ) { + if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed + || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { if (oldShader != NULL) { RB_EndSurface(); } @@ -757,7 +756,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } if (inQuery) { - inQuery = qfalse; qglEndQueryARB(GL_SAMPLES_PASSED_ARB); } diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c index 9b26241b..824e6c2b 100644 --- a/src/renderergl2/tr_bsp.c +++ b/src/renderergl2/tr_bsp.c @@ -2124,8 +2124,6 @@ static void R_CreateWorldVBO(void) } - startTime = ri.Milliseconds(); - ri.Free(surfacesSorted); ri.Hunk_FreeTempMemory(triangles); @@ -2152,7 +2150,6 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { numTriSurfs = 0; numFlares = 0; - in = (void *)(fileBase + surfs->fileofs); if (surfs->filelen % sizeof(*in)) ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = surfs->filelen / sizeof(*in); diff --git a/src/renderergl2/tr_image.c b/src/renderergl2/tr_image.c index 72a59329..6681cbd9 100644 --- a/src/renderergl2/tr_image.c +++ b/src/renderergl2/tr_image.c @@ -327,7 +327,6 @@ static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, for (i=0 ; i> 1; for (j=0 ; jinteger) internalFormat = GL_LUMINANCE; else diff --git a/src/renderergl2/tr_main.c b/src/renderergl2/tr_main.c index 2f528bb3..dc8a478c 100644 --- a/src/renderergl2/tr_main.c +++ b/src/renderergl2/tr_main.c @@ -1558,10 +1558,6 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) // translate the original plane originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); } - else - { - plane = originalPlane; - } // locate the portal entity closest to this plane. // origin will be the origin of the portal, origin2 will be diff --git a/src/renderergl2/tr_marks.c b/src/renderergl2/tr_marks.c index f510b2db..bf6980e9 100644 --- a/src/renderergl2/tr_marks.c +++ b/src/renderergl2/tr_marks.c @@ -42,8 +42,8 @@ Out must have space for two more vertexes than in static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], vec3_t normal, vec_t dist, vec_t epsilon) { - float dists[MAX_VERTS_ON_POLY+4]; - int sides[MAX_VERTS_ON_POLY+4]; + float dists[MAX_VERTS_ON_POLY+4] = { 0 }; + int sides[MAX_VERTS_ON_POLY+4] = { 0 }; int counts[3]; float dot; int i, j; diff --git a/src/renderergl2/tr_shader.c b/src/renderergl2/tr_shader.c index 06b004b1..6a42f4cb 100644 --- a/src/renderergl2/tr_shader.c +++ b/src/renderergl2/tr_shader.c @@ -1767,7 +1767,7 @@ static qboolean ParseShader( char **text ) // light determines flaring in q3map, not needed here else if ( !Q_stricmp(token, "light") ) { - token = COM_ParseExt( text, qfalse ); + COM_ParseExt( text, qfalse ); continue; } // cull @@ -2908,7 +2908,6 @@ static shader_t *FinishShader( void ) { // if ( stage > 1 && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) { VertexLightingCollapse(); - stage = 1; hasLightmapStage = qfalse; } diff --git a/src/renderergl2/tr_world.c b/src/renderergl2/tr_world.c index 95cfea36..cbce8157 100644 --- a/src/renderergl2/tr_world.c +++ b/src/renderergl2/tr_world.c @@ -636,7 +636,7 @@ R_ClusterPVS ============== */ static const byte *R_ClusterPVS (int cluster) { - if (!tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { + if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { return tr.world->novis; } -- cgit