engine: try to fix -Wmaybe-uninitialized that may be enabled with -Wuninitialized. Diagnostic is prone to false-positives, as compiler don't have enough data for this

This commit is contained in:
Alibek Omarov 2020-05-12 02:00:31 +03:00
parent a641488b98
commit 0db1a7743d
5 changed files with 42 additions and 42 deletions

View File

@ -57,7 +57,7 @@ void SCR_DrawFPS( int height )
int offset;
if( cls.state != ca_active || !cl_showfps->value || cl.background )
return;
return;
switch( cls.scrshot_action )
{
@ -203,7 +203,7 @@ void SCR_RSpeeds( void )
y += height;
// handle '\n\n'
if( *p == '\n' )
if( *p == '\n' )
y += height;
if( end ) p = end + 1;
else break;
@ -306,7 +306,7 @@ void SCR_MakeScreenShot( void )
// report
if( iRet )
{
// snapshots don't writes message about image
// snapshots don't writes message about image
if( cls.scrshot_action != scrshot_snapshot )
Con_Reportf( "Write %s\n", cls.shotname );
}
@ -342,7 +342,7 @@ SCR_BeginLoadingPlaque
*/
void SCR_BeginLoadingPlaque( qboolean is_background )
{
float oldclear;
float oldclear = 0;;
S_StopAllSounds( true );
cl.audio_prepped = false; // don't play ambients
cl.video_prepped = false;
@ -461,7 +461,7 @@ void SCR_TileClear( void )
right = left + clgame.viewport[2] - 1;
if( clear.y1 < top )
{
{
// clear above view screen
i = clear.y2 < top-1 ? clear.y2 : top - 1;
ref.dllFuncs.R_DrawTileClear( cls.tileImage, clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1 );
@ -469,7 +469,7 @@ void SCR_TileClear( void )
}
if( clear.y2 > bottom )
{
{
// clear below view screen
i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
ref.dllFuncs.R_DrawTileClear( cls.tileImage, clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1 );
@ -485,7 +485,7 @@ void SCR_TileClear( void )
}
if( clear.x2 > right )
{
{
// clear left of view screen
i = clear.x1 > right + 1 ? clear.x1 : right + 1;
ref.dllFuncs.R_DrawTileClear( cls.tileImage, i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1 );
@ -578,7 +578,7 @@ qboolean SCR_LoadVariableWidthFont( const char *fontname )
// half-life font with variable chars witdh
buffer = FS_LoadFile( fontname, &length, false );
// setup creditsfont
// setup creditsfont
if( buffer && length >= sizeof( qfont_t ))
{
src = (qfont_t *)buffer;
@ -697,7 +697,7 @@ void SCR_RegisterTextures( void )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
}
cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
}
@ -750,7 +750,7 @@ void SCR_VidInit( void )
VGui_Startup( NULL, refState.width, refState.height ); // initialized already, so pass NULL
CL_ClearSpriteTextures(); // now all hud sprites are invalid
// vid_state has changed
if( gameui.hInstance ) gameui.dllFuncs.pfnVidInit();
if( clgame.hInstance ) clgame.dllFuncs.pfnVidInit();
@ -777,7 +777,7 @@ void SCR_Init( void )
cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", FCVAR_ARCHIVE, "envshot size of cube side" );
v_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" );
scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" );
// register our commands
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
Cmd_AddCommand( "loadsky", CL_SetSky_f, "set new skybox by basename" );

View File

@ -106,7 +106,7 @@ typedef struct
// console fonts
cl_font_t chars[CON_NUMFONTS];// fonts.wad/font1.fnt
cl_font_t *curFont, *lastUsedFont;
// console input
field_t input;
@ -171,7 +171,7 @@ void Con_SetColor_f( void )
break;
}
}
/*
================
Con_ClearNotify
@ -180,7 +180,7 @@ Con_ClearNotify
void Con_ClearNotify( void )
{
int i;
for( i = 0; i < CON_LINES_COUNT; i++ )
CON_LINES( i ).addtime = 0.0;
}
@ -1599,7 +1599,7 @@ void Field_CharEvent( field_t *edit, int ch )
if( ch < 32 ) return;
if( host.key_overstrike )
{
{
if ( edit->cursor == MAX_STRING - 1 ) return;
edit->buffer[edit->cursor] = ch;
edit->cursor++;
@ -1664,7 +1664,7 @@ void Field_DrawInputLine( int x, int y, field_t *edit )
if( host.key_overstrike && cursorChar && !((int)( host.realtime * 4 ) & 1 ))
hideChar = edit->cursor - prestep; // skip this char
// draw it
Con_DrawGenericString( x, y, str, colorDefault, false, hideChar );
@ -1809,7 +1809,7 @@ void Key_Console( int key )
}
if( key == K_MWHEELDOWN )
{
{
if( Key_IsDown( K_CTRL ))
Con_PageDown( 8 );
else Con_PageDown( 2 );
@ -1909,13 +1909,13 @@ int Con_DrawDebugLines( void )
int y = 20;
defaultX = refState.width / 4;
for( i = 0; i < MAX_DBG_NOTIFY; i++ )
{
if( host.realtime < con.notify[i].expire && con.notify[i].key_dest == cls.key_dest )
{
int x, len;
int fontTall;
int fontTall = 0;
Con_DrawStringLen( con.notify[i].szNotify, &len, &fontTall );
x = refState.width - Q_max( defaultX, len ) - 10;
@ -1949,7 +1949,7 @@ void Con_DrawDebug( void )
if( scr_download->value != -1.0f )
{
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
x = refState.width - 500;
y = con.curFont->charHeight * 1.05f;
Con_DrawString( x, y, dlstring, g_color_table[7] );
@ -1998,7 +1998,7 @@ void Con_DrawNotify( void )
y += con.curFont->charHeight;
}
}
if( cls.key_dest == key_message )
{
string buf;
@ -2204,14 +2204,14 @@ void Con_DrawConsole( void )
case ca_connecting:
case ca_connected:
case ca_validate:
// force to show console always for -dev 3 and higher
// force to show console always for -dev 3 and higher
Con_DrawSolidConsole( con.vislines );
break;
case ca_active:
case ca_cinematic:
case ca_cinematic:
if( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" ))
{
if( cls.key_dest == key_console )
if( cls.key_dest == key_console )
Con_DrawSolidConsole( refState.height );
}
else
@ -2238,7 +2238,7 @@ void Con_DrawVersion( void )
{
// draws the current build
byte *color = g_color_table[7];
int i, stringLen, width = 0, charH;
int i, stringLen, width = 0, charH = 0;
int start, height = refState.height;
qboolean draw_version = false;
string curbuild;

View File

@ -41,7 +41,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
int ret;
short p, a, b, c, pa, pb, pc;
byte *buf_p, *pixbuf, *raw, *prior, *idat_buf = NULL, *uncompressed_buffer = NULL, *rowend;
uint chunk_len, crc32, crc32_check, oldsize = 0, newsize, rowsize;
uint chunk_len, crc32, crc32_check, oldsize = 0, newsize = 0, rowsize;
uint uncompressed_size, pixel_size, i, y, filter_type, chunk_sign;
qboolean has_iend_chunk = false;
z_stream stream = {0};
@ -180,7 +180,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
buf_p += chunk_len;
// get real chunk CRC
memcpy( &crc32, buf_p, sizeof( crc32 ) );
memcpy( &crc32, buf_p, sizeof( crc32 ) );
// check chunk CRC
if( ntohl( crc32 ) != crc32_check )
@ -304,7 +304,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
Con_DPrintf( S_ERROR "Image_LoadPNG: Found unknown filter type (%s)\n", name );
Mem_Free( uncompressed_buffer );
Mem_Free( image.rgba );
return false;
return false;
}
for( y = 1; y < image.height; y++ )
@ -563,7 +563,7 @@ qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
png_ftr.idat_crc32 = htonl( crc32 );
// write IEND chunk length
png_ftr.iend_len = 0;
png_ftr.iend_len = 0;
// write IEND chunk signature
memcpy( png_ftr.iend_sign, iend_sign, sizeof( iend_sign ) );

View File

@ -74,7 +74,7 @@ static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, msp
{
Q_snprintf( texname, sizeof( texname ), "#%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
gl_texturenum = GL_LoadTexture( texname, pin, pinframe.width * pinframe.height * bytes, r_texFlags );
}
}
// setup frame description
pspriteframe = Mem_Malloc( mod->mempool, sizeof( mspriteframe_t ));
@ -167,7 +167,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
if( numi == NULL )
{
rgbdata_t *pal;
pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 );
pframetype = (const dframetype_t *)((const byte*)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
@ -194,7 +194,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
pframetype = (const dframetype_t *)(src + 768);
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
}
else
else
{
gEngfuncs.Con_DPrintf( S_ERROR "%s has wrong number of palette colors %i (should be 256)\n", mod->name, *numi );
return;
@ -360,7 +360,7 @@ release sprite model and frames
void Mod_SpriteUnloadTextures( void *data )
{
msprite_t *psprite;
mspritegroup_t *pspritegroup;
mspritegroup_t *pspritegroup;
mspriteframe_t *pspriteframe;
int i, j;
@ -424,7 +424,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
{
pspriteframe = psprite->frames[frame].frameptr;
}
else if( psprite->frames[frame].type == SPR_GROUP )
else if( psprite->frames[frame].type == SPR_GROUP )
{
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
pintervals = pspritegroup->intervals;
@ -537,7 +537,7 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
if( oldframe ) *oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
if( curframe ) *curframe = psprite->frames[frame].frameptr;
}
else if( psprite->frames[frame].type == FRAME_GROUP )
else if( psprite->frames[frame].type == FRAME_GROUP )
{
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
pintervals = pspritegroup->intervals;
@ -718,7 +718,7 @@ qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
return true;
}
return false;
return false;
}
/*
@ -756,7 +756,7 @@ static qboolean R_SpriteHasLightmap( cl_entity_t *e, int texFormat )
{
if( !r_sprite_lighting->value )
return false;
if( texFormat != SPR_ALPHTEST )
return false;
@ -815,7 +815,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
float angle, dot, sr, cr;
float lerp = 1.0f, ilerp, scale;
vec3_t v_forward, v_right, v_up;
vec3_t origin, color, color2;
vec3_t origin, color, color2 = { 0.0f };
if( RI.params & RP_ENVVIEW )
return;
@ -828,7 +828,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
if( e->curstate.aiment > 0 && e->curstate.movetype == MOVETYPE_FOLLOW )
{
cl_entity_t *parent;
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model )
@ -948,14 +948,14 @@ void R_DrawSpriteModel( cl_entity_t *e )
break;
case SPR_FWD_PARALLEL: // normal sprite
default:
VectorCopy( RI.vright, v_right );
VectorCopy( RI.vright, v_right );
VectorCopy( RI.vup, v_up );
break;
}
if( psprite->facecull == SPR_CULL_NONE )
GL_Cull( GL_NONE );
if( oldframe == frame )
{
// draw the single non-lerped frame

View File

@ -198,7 +198,7 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
int i, total_segs, segs_drawn;
float div, length, fraction, factor;
float flMaxWidth, vLast, vStep, brightness;
vec3_t perp1, vLastNormal;
vec3_t perp1, vLastNormal = { 0.0f };
beamseg_t curSeg;
if( segments < 2 ) return;