Browse Source

engine: fix -Wmaybe-uninitialized

pull/2/head
Alibek Omarov 5 years ago
parent
commit
0fe18ae6dc
  1. 4
      engine/common/imagelib/img_png.c
  2. 2
      engine/common/mod_bmodel.c
  3. 3
      engine/common/mod_sprite.c
  4. 24
      engine/common/mod_studio.c
  5. 2
      engine/common/system.h
  6. 4
      engine/server/sv_game.c
  7. 2
      mainui
  8. 2
      public/crtlib.h
  9. 2
      ref_gl/gl_alias.c
  10. 22
      ref_gl/gl_image.c
  11. 1
      wscript

4
engine/common/imagelib/img_png.c

@ -217,6 +217,10 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
case PNG_CT_RGBA: case PNG_CT_RGBA:
pixel_size = 4; pixel_size = 4;
break; break;
default:
pixel_size = 0; // make compiler happy
ASSERT( false );
break;
} }
image.type = PF_RGBA_32; // always exctracted to 32-bit buffer image.type = PF_RGBA_32; // always exctracted to 32-bit buffer

2
engine/common/mod_bmodel.c

@ -1975,7 +1975,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
if( mt->offsets[0] > 0 ) if( mt->offsets[0] > 0 )
{ {
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6); int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
int next_dataofs, remaining; int next_dataofs = 0, remaining;
// compute next dataofset to determine allocated miptex space // compute next dataofset to determine allocated miptex space
for( j = i + 1; j < loadmodel->numtextures; j++ ) for( j = i + 1; j < loadmodel->numtextures; j++ )

3
engine/common/mod_sprite.c

@ -80,7 +80,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
mod->mins[2] = -pinq1->bounds[1] * 0.5f; mod->mins[2] = -pinq1->bounds[1] * 0.5f;
mod->maxs[2] = pinq1->bounds[1] * 0.5f; mod->maxs[2] = pinq1->bounds[1] * 0.5f;
} }
else if( i == SPRITE_VERSION_HL ) else // if( i == SPRITE_VERSION_HL )
{ {
pinhl = (dsprite_hl_t *)buffer; pinhl = (dsprite_hl_t *)buffer;
size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames ); size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames );
@ -104,7 +104,6 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
if( Host_IsDedicated() ) if( Host_IsDedicated() )
{ {
// skip frames loading // skip frames loading
psprite->numframes = 0; psprite->numframes = 0;
return; return;
} }

24
engine/common/mod_studio.c

@ -320,19 +320,19 @@ static void Mod_StudioCalcBoneAdj( float *adj, const byte *pcontroller )
if( i == STUDIO_MOUTH ) if( i == STUDIO_MOUTH )
continue; // ignore mouth continue; // ignore mouth
if( i <= MAXSTUDIOCONTROLLERS ) if( i >= MAXSTUDIOCONTROLLERS )
continue;
// check for 360% wrapping
if( pbonecontroller[j].type & STUDIO_RLOOP )
{ {
// check for 360% wrapping value = pcontroller[i] * (360.0f / 256.0f) + pbonecontroller[j].start;
if( pbonecontroller[j].type & STUDIO_RLOOP ) }
{ else
value = pcontroller[i] * (360.0f / 256.0f) + pbonecontroller[j].start; {
} value = pcontroller[i] / 255.0f;
else value = bound( 0.0f, value, 1.0f );
{ value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end;
value = pcontroller[i] / 255.0f;
value = bound( 0.0f, value, 1.0f );
value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end;
}
} }
switch( pbonecontroller[j].type & STUDIO_TYPES ) switch( pbonecontroller[j].type & STUDIO_TYPES )

2
engine/common/system.h

@ -68,7 +68,7 @@ void Sys_Print( const char *pMsg );
void Sys_PrintLog( const char *pMsg ); void Sys_PrintLog( const char *pMsg );
void Sys_InitLog( void ); void Sys_InitLog( void );
void Sys_CloseLog( void ); void Sys_CloseLog( void );
void Sys_Quit( void ); void Sys_Quit( void ) NORETURN;
// //
// sys_con.c // sys_con.c

4
engine/server/sv_game.c

@ -1296,7 +1296,7 @@ void pfnSetModel( edict_t *e, const char *m )
char name[MAX_QPATH]; char name[MAX_QPATH];
qboolean found = false; qboolean found = false;
model_t *mod; model_t *mod;
int i; int i = 1;
if( !SV_IsValidEdict( e )) if( !SV_IsValidEdict( e ))
return; return;
@ -1308,7 +1308,7 @@ void pfnSetModel( edict_t *e, const char *m )
if( COM_CheckString( name )) if( COM_CheckString( name ))
{ {
// check to see if model was properly precached // check to see if model was properly precached
for( i = 1; i < MAX_MODELS && sv.model_precache[i][0]; i++ ) for( ; i < MAX_MODELS && sv.model_precache[i][0]; i++ )
{ {
if( !Q_stricmp( sv.model_precache[i], name )) if( !Q_stricmp( sv.model_precache[i], name ))
{ {

2
mainui

@ -1 +1 @@
Subproject commit 095661b44b5ef3bff4fe887de92bbe8cfc2fc6fd Subproject commit f197117dacd1938fe3afca34716e4b7b60b6f837

2
public/crtlib.h

@ -21,8 +21,10 @@ GNU General Public License for more details.
#ifdef __GNUC__ #ifdef __GNUC__
#define _format(x) __attribute__((format(printf, x, x+1))) #define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn))
#else #else
#define _format(x) #define _format(x)
#define NORETURN
#endif #endif
// timestamp modes // timestamp modes

2
ref_gl/gl_alias.c

@ -227,7 +227,7 @@ for the model, which holds for all frames
*/ */
void BuildTris( void ) void BuildTris( void )
{ {
int len, bestlen, besttype; int len, bestlen, besttype = 0;
int bestverts[1024]; int bestverts[1024];
int besttris[1024]; int besttris[1024];
int type, startv; int type, startv;

22
ref_gl/gl_image.c

@ -481,7 +481,7 @@ static size_t GL_CalcTextureSize( GLenum format, int width, int height, int dept
return size; return size;
} }
static int GL_CalcMipmapCount( gl_texture_t *tex, qboolean haveBuffer ) static int GL_CalcMipmapCount( gl_texture_t *tex, qboolean haveBuffer )
{ {
int width, height; int width, height;
int mipcount; int mipcount;
@ -494,7 +494,7 @@ static int GL_CalcMipmapCount( gl_texture_t *tex, qboolean haveBuffer )
// generate mip-levels by user request // generate mip-levels by user request
if( FBitSet( tex->flags, TF_NOMIPMAP )) if( FBitSet( tex->flags, TF_NOMIPMAP ))
return 1; return 1;
// mip-maps can't exceeds 16 // mip-maps can't exceeds 16
for( mipcount = 0; mipcount < 16; mipcount++ ) for( mipcount = 0; mipcount < 16; mipcount++ )
{ {
@ -514,7 +514,7 @@ GL_SetTextureDimensions
*/ */
static void GL_SetTextureDimensions( gl_texture_t *tex, int width, int height, int depth ) static void GL_SetTextureDimensions( gl_texture_t *tex, int width, int height, int depth )
{ {
int maxTextureSize; int maxTextureSize = 0;
int maxDepthSize = 1; int maxDepthSize = 1;
Assert( tex != NULL ); Assert( tex != NULL );
@ -539,6 +539,8 @@ static void GL_SetTextureDimensions( gl_texture_t *tex, int width, int height, i
maxDepthSize = glConfig.max_3d_texture_size; maxDepthSize = glConfig.max_3d_texture_size;
maxTextureSize = glConfig.max_3d_texture_size; maxTextureSize = glConfig.max_3d_texture_size;
break; break;
default:
Assert( false );
} }
// store original sizes // store original sizes
@ -717,7 +719,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
switch( GL_CalcTextureSamples( channelMask )) switch( GL_CalcTextureSamples( channelMask ))
{ {
case 1: case 1:
if( FBitSet( tex->flags, TF_ALPHACONTRAST )) if( FBitSet( tex->flags, TF_ALPHACONTRAST ))
tex->format = GL_INTENSITY8; tex->format = GL_INTENSITY8;
else tex->format = GL_LUMINANCE8; else tex->format = GL_LUMINANCE8;
@ -730,7 +732,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
case 32: tex->format = GL_RGB8; break; case 32: tex->format = GL_RGB8; break;
default: tex->format = GL_RGB; break; default: tex->format = GL_RGB; break;
} }
break; break;
case 4: case 4:
default: default:
switch( bits ) switch( bits )
@ -1233,7 +1235,7 @@ do specified actions on pixels
static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic ) static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic )
{ {
float emboss_scale = 0.0f; float emboss_scale = 0.0f;
uint img_flags = 0; uint img_flags = 0;
// force upload texture as RGB or RGBA (detail textures requires this) // force upload texture as RGB or RGBA (detail textures requires this)
if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR; if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR;
@ -1472,7 +1474,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags )
SetBits( picFlags, IL_DONTFLIP_TGA ); SetBits( picFlags, IL_DONTFLIP_TGA );
if( FBitSet( flags, TF_KEEP_SOURCE ) && !FBitSet( flags, TF_EXPAND_SOURCE )) if( FBitSet( flags, TF_KEEP_SOURCE ) && !FBitSet( flags, TF_EXPAND_SOURCE ))
SetBits( picFlags, IL_KEEP_8BIT ); SetBits( picFlags, IL_KEEP_8BIT );
// set some image flags // set some image flags
gEngfuncs.Image_SetForceFlags( picFlags ); gEngfuncs.Image_SetForceFlags( picFlags );
@ -1615,7 +1617,7 @@ int GL_LoadTextureArray( const char **names, int flags )
gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: not all layers were loaded. Texture array is not created\n" ); gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: not all layers were loaded. Texture array is not created\n" );
if( pic ) gEngfuncs.FS_FreeImage( pic ); if( pic ) gEngfuncs.FS_FreeImage( pic );
return 0; return 0;
} }
// it's multilayer image! // it's multilayer image!
SetBits( pic->flags, IMAGE_MULTILAYER ); SetBits( pic->flags, IMAGE_MULTILAYER );
@ -1923,7 +1925,7 @@ void R_InitDlightTexture( void )
return; // already initialized return; // already initialized
memset( &r_image, 0, sizeof( r_image )); memset( &r_image, 0, sizeof( r_image ));
r_image.width = BLOCK_SIZE; r_image.width = BLOCK_SIZE;
r_image.height = BLOCK_SIZE; r_image.height = BLOCK_SIZE;
r_image.flags = IMAGE_HAS_COLOR; r_image.flags = IMAGE_HAS_COLOR;
r_image.type = PF_RGBA_32; r_image.type = PF_RGBA_32;
@ -2100,7 +2102,7 @@ void R_TextureList_f( void )
case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT24:
gEngfuncs.Con_Printf( "DPTH24" ); gEngfuncs.Con_Printf( "DPTH24" );
break; break;
case GL_DEPTH_COMPONENT32F: case GL_DEPTH_COMPONENT32F:
gEngfuncs.Con_Printf( "DPTH32" ); gEngfuncs.Con_Printf( "DPTH32" );
break; break;

1
wscript

@ -237,6 +237,7 @@ def configure(conf):
'-Werror=bool-compare', '-Werror=bool-compare',
'-Werror=bool-operation', '-Werror=bool-operation',
'-Werror=uninitialized', '-Werror=uninitialized',
'-Werror=init-self',
'-Werror=implicit-fallthrough=2', # clang incompatible without "=2" '-Werror=implicit-fallthrough=2', # clang incompatible without "=2"
# '-Wdouble-promotion', # disable warning flood # '-Wdouble-promotion', # disable warning flood
'-Wstrict-aliasing', '-Wstrict-aliasing',

Loading…
Cancel
Save