From 98360bcd578cbd60f910c42bc0fa1a9bb698def8 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 26 Mar 2013 16:50:03 +0000 Subject: [PATCH] Fix some of the things clang --analyze flagged --- code/botlib/be_aas_reach.c | 8 +++++--- code/botlib/be_aas_route.c | 7 +++---- code/botlib/be_ai_chat.c | 16 +++++++--------- code/botlib/be_ai_weap.c | 6 ------ code/botlib/be_ai_weight.c | 1 - code/botlib/l_precomp.c | 11 +---------- code/client/cl_console.c | 2 -- code/client/snd_adpcm.c | 2 +- code/client/snd_dma.c | 1 - code/client/snd_mix.c | 2 +- code/client/snd_openal.c | 2 -- code/client/snd_wavelet.c | 6 +++--- code/qcommon/cm_polylib.c | 8 ++++---- code/qcommon/cm_trace.c | 8 ++++++-- code/qcommon/common.c | 3 --- code/qcommon/files.c | 1 - code/qcommon/huffman.c | 2 -- code/qcommon/unzip.c | 14 ++++---------- code/renderercommon/tr_image_bmp.c | 1 - code/renderercommon/tr_image_png.c | 1 - code/renderercommon/tr_image_tga.c | 5 ----- code/renderergl1/tr_backend.c | 12 ++++++------ code/renderergl1/tr_image.c | 1 - code/renderergl1/tr_main.c | 4 ---- code/renderergl1/tr_marks.c | 4 ++-- code/renderergl1/tr_shader.c | 2 +- code/renderergl1/tr_world.c | 2 +- code/renderergl2/tr_backend.c | 14 ++++++-------- code/renderergl2/tr_bsp.c | 3 --- code/renderergl2/tr_image.c | 8 +++----- code/renderergl2/tr_main.c | 4 ---- code/renderergl2/tr_marks.c | 4 ++-- code/renderergl2/tr_shader.c | 3 +-- code/renderergl2/tr_world.c | 2 +- 34 files changed, 58 insertions(+), 112 deletions(-) diff --git a/code/botlib/be_aas_reach.c b/code/botlib/be_aas_reach.c index 3a4564ca..ed9ff76d 100644 --- a/code/botlib/be_aas_reach.c +++ b/code/botlib/be_aas_reach.c @@ -3237,8 +3237,10 @@ aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int numpoint // if (towardsface) VectorCopy(bestend, testpoint); else VectorCopy(beststart, testpoint); - testpoint[2] = 0; - testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2]; + if (bestfaceplane != NULL) + testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2]; + else + testpoint[2] = 0; // if (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f)) { @@ -3786,7 +3788,7 @@ int AAS_Reachability_Grapple(int area1num, int area2num) aas_face_t *face2; aas_area_t *area1, *area2; aas_lreachability_t *lreach; - vec3_t areastart, facecenter, start, end, dir, down = {0, 0, -1}; + vec3_t areastart = {0, 0, 0}, facecenter, start, end, dir, down = {0, 0, -1}; vec_t *v; //only grapple when on the ground or swimming diff --git a/code/botlib/be_aas_route.c b/code/botlib/be_aas_route.c index 5e365973..d4287a04 100644 --- a/code/botlib/be_aas_route.c +++ b/code/botlib/be_aas_route.c @@ -168,12 +168,11 @@ void AAS_InitTravelFlagFromType(void) //=========================================================================== static ID_INLINE int AAS_TravelFlagForType_inline(int traveltype) { - int tfl; + int tfl = 0; - tfl = 0; - if (tfl & TRAVELFLAG_NOTTEAM1) + if (traveltype & TRAVELFLAG_NOTTEAM1) tfl |= TFL_NOTTEAM1; - if (tfl & TRAVELFLAG_NOTTEAM2) + if (traveltype & TRAVELFLAG_NOTTEAM2) tfl |= TFL_NOTTEAM2; traveltype &= TRAVELTYPE_MASK; if (traveltype < 0 || traveltype >= MAX_TRAVELTYPES) diff --git a/code/botlib/be_ai_chat.c b/code/botlib/be_ai_chat.c index 867e4391..35366e0f 100644 --- a/code/botlib/be_ai_chat.c +++ b/code/botlib/be_ai_chat.c @@ -673,7 +673,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename) else if (!strcmp(token.string, "[")) { size += sizeof(bot_synonymlist_t); - if (pass) + if (pass && ptr) { syn = (bot_synonymlist_t *) ptr; ptr += sizeof(bot_synonymlist_t); @@ -705,7 +705,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename) len = strlen(token.string) + 1; len = PAD(len, sizeof(long)); size += sizeof(bot_synonym_t) + len; - if (pass) + if (pass && ptr) { synonym = (bot_synonym_t *) ptr; ptr += sizeof(bot_synonym_t); @@ -725,7 +725,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename) FreeSource(source); return NULL; } //end if - if (pass) + if (pass && ptr) { synonym->weight = token.floatvalue; syn->totalweight += synonym->weight; @@ -1003,7 +1003,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename) len = strlen(token.string) + 1; len = PAD(len, sizeof(long)); size += sizeof(bot_randomlist_t) + len; - if (pass) + if (pass && ptr) { random = (bot_randomlist_t *) ptr; ptr += sizeof(bot_randomlist_t); @@ -1034,7 +1034,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename) len = strlen(chatmessagestring) + 1; len = PAD(len, sizeof(long)); size += sizeof(bot_randomstring_t) + len; - if (pass) + if (pass && ptr) { randomstring = (bot_randomstring_t *) ptr; ptr += sizeof(bot_randomstring_t); @@ -2113,7 +2113,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) return NULL; } //end if StripDoubleQuotes(token.string); - if (pass) + if (pass && ptr) { chattype = (bot_chattype_t *) ptr; strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME); @@ -2136,7 +2136,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) } //end if len = strlen(chatmessagestring) + 1; len = PAD(len, sizeof(long)); - if (pass) + if (pass && ptr) { chatmessage = (bot_chatmessage_t *) ptr; chatmessage->time = -2*CHATMESSAGE_RECENTTIME; @@ -2583,7 +2583,6 @@ void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *v strcat(match.string, var7); match.variables[7].offset = index; match.variables[7].length = strlen(var7); - index += strlen(var7); } // BotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse); @@ -2766,7 +2765,6 @@ int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char strcat(bestmatch.string, var7); bestmatch.variables[7].offset = index; bestmatch.variables[7].length = strlen(var7); - index += strlen(var7); } if (LibVarGetValue("bot_testrchat")) { diff --git a/code/botlib/be_ai_weap.c b/code/botlib/be_ai_weap.c index 39b249c0..def1f83c 100644 --- a/code/botlib/be_ai_weap.c +++ b/code/botlib/be_ai_weap.c @@ -446,12 +446,6 @@ void BotResetWeaponState(int weaponstate) ws = BotWeaponStateFromHandle(weaponstate); if (!ws) return; - weaponweightconfig = ws->weaponweightconfig; - weaponweightindex = ws->weaponweightindex; - - //Com_Memset(ws, 0, sizeof(bot_weaponstate_t)); - ws->weaponweightconfig = weaponweightconfig; - ws->weaponweightindex = weaponweightindex; } //end of the function BotResetWeaponState //======================================================================== // diff --git a/code/botlib/be_ai_weight.c b/code/botlib/be_ai_weight.c index 9f3d0f74..a6a478e3 100644 --- a/code/botlib/be_ai_weight.c +++ b/code/botlib/be_ai_weight.c @@ -272,7 +272,6 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source) fs->child = NULL; if (lastfs) lastfs->next = fs; else firstfs = fs; - lastfs = fs; } //end if // return firstfs; diff --git a/code/botlib/l_precomp.c b/code/botlib/l_precomp.c index e427d8a2..bfa7564c 100644 --- a/code/botlib/l_precomp.c +++ b/code/botlib/l_precomp.c @@ -414,7 +414,6 @@ int PC_ReadDefineParms(source_t *source, define_t *define, token_t **parms, int if (indent <= 0) { if (lastcomma) SourceWarning(source, "too many comma's"); - lastcomma = 1; break; } //end if } //end if @@ -783,7 +782,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define int PC_ExpandDefine(source_t *source, token_t *deftoken, define_t *define, token_t **firsttoken, token_t **lasttoken) { - token_t *parms[MAX_DEFINEPARMS], *dt, *pt, *t; + token_t *parms[MAX_DEFINEPARMS] = { NULL }, *dt, *pt, *t; token_t *t1, *t2, *first, *last, *nextpt, token; int parmnum, i; @@ -1209,12 +1208,6 @@ int PC_Directive_define(source_t *source) //unread the define name before executing the #undef directive PC_UnreadSourceToken(source, &token); if (!PC_Directive_undef(source)) return qfalse; - //if the define was not removed (define->flags & DEFINE_FIXED) -#if DEFINEHASHING - define = PC_FindHashedDefine(source->definehash, token.string); -#else - define = PC_FindDefine(source->defines, token.string); -#endif //DEFINEHASHING } //end if //allocate define define = (define_t *) GetMemory(sizeof(define_t)); @@ -2096,7 +2089,6 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval if (v->prev) v->prev->next = v->next; else firstvalue = v->next; if (v->next) v->next->prev = v->prev; - else lastvalue = v->prev; //FreeMemory(v); FreeValue(v); } //end if @@ -2104,7 +2096,6 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval if (o->prev) o->prev->next = o->next; else firstoperator = o->next; if (o->next) o->next->prev = o->prev; - else lastoperator = o->prev; //FreeMemory(o); FreeOperator(o); } //end while diff --git a/code/client/cl_console.c b/code/client/cl_console.c index bc34e151..4c117ecd 100644 --- a/code/client/cl_console.c +++ b/code/client/cl_console.c @@ -615,8 +615,6 @@ void Con_DrawNotify (void) Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue ); - - v += BIGCHAR_HEIGHT; } } diff --git a/code/client/snd_adpcm.c b/code/client/snd_adpcm.c index 89e68f42..4e138726 100644 --- a/code/client/snd_adpcm.c +++ b/code/client/snd_adpcm.c @@ -310,7 +310,7 @@ void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) { newchunk = SND_malloc(); if (sfx->soundData == NULL) { sfx->soundData = newchunk; - } else { + } else if (chunk != NULL) { chunk->next = newchunk; } chunk = newchunk; diff --git a/code/client/snd_dma.c b/code/client/snd_dma.c index b431994c..d4ba8906 100644 --- a/code/client/snd_dma.c +++ b/code/client/snd_dma.c @@ -1452,7 +1452,6 @@ void S_UpdateBackgroundTrack( void ) { r = S_CodecReadStream(s_backgroundStream, fileBytes, raw); if(r < fileBytes) { - fileBytes = r; fileSamples = r / (s_backgroundStream->info.width * s_backgroundStream->info.channels); } diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c index 11de66da..74a42ace 100644 --- a/code/client/snd_mix.c +++ b/code/client/snd_mix.c @@ -598,7 +598,7 @@ void S_PaintChannelFromMuLaw( channel_t *ch, sfx_t *sc, int count, int sampleOff samp[i].left += (data * leftvol)>>8; samp[i].right += (data * rightvol)>>8; samples++; - if (samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) { + if (chunk != NULL && samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) { chunk = chunk->next; samples = (byte *)chunk->sndChunk; } diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index 38f4922d..aa96c4ab 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -2496,8 +2496,6 @@ qboolean S_AL_Init( soundInterface_t *si ) devicelist += curlen + 1; } } - else - devicelist = ""; s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART); } diff --git a/code/client/snd_wavelet.c b/code/client/snd_wavelet.c index 9940b4f9..a325ffdc 100644 --- a/code/client/snd_wavelet.c +++ b/code/client/snd_wavelet.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void daub4(float b[], unsigned long n, int isign) { - float wksp[4097]; + float wksp[4097] = { 0.0f }; float *a=b-1; // numerical recipies so a[1] = b[0] unsigned long nh,nh1,i,j; @@ -146,7 +146,7 @@ void encodeWavelet( sfx_t *sfx, short *packets) { newchunk = SND_malloc(); if (sfx->soundData == NULL) { sfx->soundData = newchunk; - } else { + } else if (chunk != NULL) { chunk->next = newchunk; } chunk = newchunk; @@ -215,7 +215,7 @@ void encodeMuLaw( sfx_t *sfx, short *packets) { newchunk = SND_malloc(); if (sfx->soundData == NULL) { sfx->soundData = newchunk; - } else { + } else if (chunk != NULL) { chunk->next = newchunk; } chunk = newchunk; diff --git a/code/qcommon/cm_polylib.c b/code/qcommon/cm_polylib.c index 500b1df1..4fa97865 100644 --- a/code/qcommon/cm_polylib.c +++ b/code/qcommon/cm_polylib.c @@ -309,8 +309,8 @@ ClipWindingEpsilon void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, vec_t epsilon, winding_t **front, winding_t **back) { - vec_t dists[MAX_POINTS_ON_WINDING+4]; - int sides[MAX_POINTS_ON_WINDING+4]; + vec_t dists[MAX_POINTS_ON_WINDING+4] = { 0 }; + int sides[MAX_POINTS_ON_WINDING+4] = { 0 }; int counts[3]; static vec_t dot; // VC 4.2 optimizer bug if not static int i, j; @@ -421,8 +421,8 @@ ChopWindingInPlace void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon) { winding_t *in; - vec_t dists[MAX_POINTS_ON_WINDING+4]; - int sides[MAX_POINTS_ON_WINDING+4]; + vec_t dists[MAX_POINTS_ON_WINDING+4] = { 0 }; + int sides[MAX_POINTS_ON_WINDING+4] = { 0 }; int counts[3]; static vec_t dot; // VC 4.2 optimizer bug if not static int i, j; diff --git a/code/qcommon/cm_trace.c b/code/qcommon/cm_trace.c index ea71cf48..a4ac80a5 100644 --- a/code/qcommon/cm_trace.c +++ b/code/qcommon/cm_trace.c @@ -650,8 +650,12 @@ void CM_TraceThroughBrush( traceWork_t *tw, cbrush_t *brush ) { enterFrac = 0; } tw->trace.fraction = enterFrac; - tw->trace.plane = *clipplane; - tw->trace.surfaceFlags = leadside->surfaceFlags; + if (clipplane != NULL) { + tw->trace.plane = *clipplane; + } + if (leadside != NULL) { + tw->trace.surfaceFlags = leadside->surfaceFlags; + } tw->trace.contents = brush->contents; } } diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 60aee7b1..7cfd77bd 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -887,9 +887,6 @@ void Z_Free( void *ptr ) { block->size += other->size; block->next = other->next; block->next->prev = block; - if (other == zone->rover) { - zone->rover = block; - } } } diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 33a1b7d0..d49c85b3 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -1671,7 +1671,6 @@ int FS_Seek( fileHandle_t f, long offset, int origin ) { _origin = SEEK_SET; break; default: - _origin = SEEK_CUR; Com_Error( ERR_FATAL, "Bad origin in FS_Seek" ); break; } diff --git a/code/qcommon/huffman.c b/code/qcommon/huffman.c index 941258c2..c1b9f242 100644 --- a/code/qcommon/huffman.c +++ b/code/qcommon/huffman.c @@ -405,7 +405,6 @@ void Huff_Compress(msg_t *mbuf, int offset) { huff.tree->weight = 0; huff.lhead->next = huff.lhead->prev = NULL; huff.tree->parent = huff.tree->left = huff.tree->right = NULL; - huff.loc[NYT] = huff.tree; seq[0] = (size>>8); seq[1] = size&0xff; @@ -442,6 +441,5 @@ void Huff_Init(huffman_t *huff) { huff->compressor.tree->weight = 0; huff->compressor.lhead->next = huff->compressor.lhead->prev = NULL; huff->compressor.tree->parent = huff->compressor.tree->left = huff->compressor.tree->right = NULL; - huff->compressor.loc[NYT] = huff->compressor.tree; } diff --git a/code/qcommon/unzip.c b/code/qcommon/unzip.c index 2dd0bf83..4fb2d3a9 100644 --- a/code/qcommon/unzip.c +++ b/code/qcommon/unzip.c @@ -713,18 +713,13 @@ local int unzlocal_GetCurrentFileInfoInternal (file, if (lSeek!=0) { - if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else + if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)!=0) err=UNZ_ERRNO; } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; } - else - lSeek+=file_info.size_file_comment; if ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; @@ -1144,13 +1139,12 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) pfile_in_zip_read_info->stream.next_in = (voidpf)0; pfile_in_zip_read_info->stream.avail_in = 0; - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) + if (inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS) == Z_OK) pfile_in_zip_read_info->stream_initialised=1; else { TRYFREE(pfile_in_zip_read_info); - return err; + return UNZ_INTERNALERROR; } /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte @@ -1197,7 +1191,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) # endif - return UNZ_OK; + return err; } extern int ZEXPORT unzOpenCurrentFile (file) diff --git a/code/renderercommon/tr_image_bmp.c b/code/renderercommon/tr_image_bmp.c index 0708f8e5..594b308d 100644 --- a/code/renderercommon/tr_image_bmp.c +++ b/code/renderercommon/tr_image_bmp.c @@ -119,7 +119,6 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height ) ri.Error( ERR_DROP, "LoadBMP: header too short (%s)", name ); Com_Memcpy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ) ); - buf_p += sizeof(bmpHeader.palette); } if (buffer.b + bmpHeader.bitmapDataOffset > end) diff --git a/code/renderercommon/tr_image_png.c b/code/renderercommon/tr_image_png.c index aad794e7..532454c5 100644 --- a/code/renderercommon/tr_image_png.c +++ b/code/renderercommon/tr_image_png.c @@ -540,7 +540,6 @@ static uint32_t DecompressIDATs(struct BufferedFile *BF, uint8_t **Buffer) */ DecompressedData = NULL; - DecompressedDataLength = 0; *Buffer = DecompressedData; CompressedData = NULL; diff --git a/code/renderercommon/tr_image_tga.c b/code/renderercommon/tr_image_tga.c index b1dd5157..bcfd0467 100644 --- a/code/renderercommon/tr_image_tga.c +++ b/code/renderercommon/tr_image_tga.c @@ -192,11 +192,6 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height) else if (targa_header.image_type==10) { // Runlength encoded RGB images unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j; - red = 0; - green = 0; - blue = 0; - alphabyte = 0xff; - for(row=rows-1; row>=0; row--) { pixbuf = targa_rgba + row*columns*4; for(column=0; columnframeUsed = tr.frameCount; + if ( image ) { + image->frameUsed = tr.frameCount; + } glState.currenttextures[glState.currenttmu] = texnum; qglBindTexture (GL_TEXTURE_2D, texnum); } @@ -215,7 +217,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 ) ) { @@ -249,7 +251,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; } @@ -281,7 +282,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; } @@ -545,8 +545,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 - || ( entityNum != oldEntityNum && !shader->entityMergable ) ) { + if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted + || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { if (oldShader != NULL) { RB_EndSurface(); } diff --git a/code/renderergl1/tr_image.c b/code/renderergl1/tr_image.c index f5afb06e..14cf9890 100644 --- a/code/renderergl1/tr_image.c +++ b/code/renderergl1/tr_image.c @@ -326,7 +326,6 @@ static void ResampleTexture( unsigned *in, int inwidth, int inheight, unsigned * for (i=0 ; i> 1; for (j=0 ; j determines flaring in q3map, not needed here else if ( !Q_stricmp(token, "light") ) { - token = COM_ParseExt( text, qfalse ); + (void)COM_ParseExt( text, qfalse ); continue; } // cull diff --git a/code/renderergl1/tr_world.c b/code/renderergl1/tr_world.c index de0ed339..0a2743f9 100644 --- a/code/renderergl1/tr_world.c +++ b/code/renderergl1/tr_world.c @@ -530,7 +530,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; } diff --git a/code/renderergl2/tr_backend.c b/code/renderergl2/tr_backend.c index ba1146c9..43510699 100644 --- a/code/renderergl2/tr_backend.c +++ b/code/renderergl2/tr_backend.c @@ -53,7 +53,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); } @@ -251,7 +253,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 ) ) { @@ -285,7 +287,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; } @@ -317,7 +318,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; } @@ -607,7 +607,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; @@ -630,8 +629,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(); } @@ -756,7 +755,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } if (inQuery) { - inQuery = qfalse; qglEndQueryARB(GL_SAMPLES_PASSED_ARB); } diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index a2d25da9..abb3c1a1 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -2123,8 +2123,6 @@ static void R_CreateWorldVBO(void) } - startTime = ri.Milliseconds(); - ri.Free(surfacesSorted); ri.Hunk_FreeTempMemory(triangles); @@ -2151,7 +2149,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/code/renderergl2/tr_image.c b/code/renderergl2/tr_image.c index b1bec4b0..c9ca6ce6 100644 --- a/code/renderergl2/tr_image.c +++ b/code/renderergl2/tr_image.c @@ -326,7 +326,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/code/renderergl2/tr_main.c b/code/renderergl2/tr_main.c index 17a7f1ba..b67c5fa4 100644 --- a/code/renderergl2/tr_main.c +++ b/code/renderergl2/tr_main.c @@ -1557,10 +1557,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/code/renderergl2/tr_marks.c b/code/renderergl2/tr_marks.c index f24459e2..4d070565 100644 --- a/code/renderergl2/tr_marks.c +++ b/code/renderergl2/tr_marks.c @@ -41,8 +41,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/code/renderergl2/tr_shader.c b/code/renderergl2/tr_shader.c index b4ffe666..658b9b92 100644 --- a/code/renderergl2/tr_shader.c +++ b/code/renderergl2/tr_shader.c @@ -1766,7 +1766,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 @@ -2907,7 +2907,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/code/renderergl2/tr_world.c b/code/renderergl2/tr_world.c index 950ee6a4..0224dbdb 100644 --- a/code/renderergl2/tr_world.c +++ b/code/renderergl2/tr_world.c @@ -635,7 +635,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; }