Browse Source

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

pull/2/head
Alibek Omarov 4 years ago
parent
commit
0db1a7743d
  1. 22
      engine/client/cl_scrn.c
  2. 28
      engine/client/console.c
  3. 8
      engine/common/imagelib/img_png.c
  4. 24
      ref_gl/gl_sprite.c
  5. 2
      ref_soft/r_beams.c

22
engine/client/cl_scrn.c

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

28
engine/client/console.c

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

8
engine/common/imagelib/img_png.c

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

24
ref_gl/gl_sprite.c

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

2
ref_soft/r_beams.c

@ -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; int i, total_segs, segs_drawn;
float div, length, fraction, factor; float div, length, fraction, factor;
float flMaxWidth, vLast, vStep, brightness; float flMaxWidth, vLast, vStep, brightness;
vec3_t perp1, vLastNormal; vec3_t perp1, vLastNormal = { 0.0f };
beamseg_t curSeg; beamseg_t curSeg;
if( segments < 2 ) return; if( segments < 2 ) return;

Loading…
Cancel
Save