diff --git a/engine/common/imagelib/img_png.c b/engine/common/imagelib/img_png.c index 788365db..73bef966 100644 --- a/engine/common/imagelib/img_png.c +++ b/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: pixel_size = 4; break; + default: + pixel_size = 0; // make compiler happy + ASSERT( false ); + break; } image.type = PF_RGBA_32; // always exctracted to 32-bit buffer diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index 228b06a8..e220a79f 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -1975,7 +1975,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) if( mt->offsets[0] > 0 ) { 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 for( j = i + 1; j < loadmodel->numtextures; j++ ) diff --git a/engine/common/mod_sprite.c b/engine/common/mod_sprite.c index 62592ee0..5cc31827 100644 --- a/engine/common/mod_sprite.c +++ b/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->maxs[2] = pinq1->bounds[1] * 0.5f; } - else if( i == SPRITE_VERSION_HL ) + else // if( i == SPRITE_VERSION_HL ) { pinhl = (dsprite_hl_t *)buffer; 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() ) { // skip frames loading - psprite->numframes = 0; return; } diff --git a/engine/common/mod_studio.c b/engine/common/mod_studio.c index 4af4d1fd..b8c0ede6 100644 --- a/engine/common/mod_studio.c +++ b/engine/common/mod_studio.c @@ -320,19 +320,19 @@ static void Mod_StudioCalcBoneAdj( float *adj, const byte *pcontroller ) if( i == STUDIO_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 - if( pbonecontroller[j].type & STUDIO_RLOOP ) - { - value = pcontroller[i] * (360.0f / 256.0f) + pbonecontroller[j].start; - } - else - { - value = pcontroller[i] / 255.0f; - value = bound( 0.0f, value, 1.0f ); - value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; - } + value = pcontroller[i] * (360.0f / 256.0f) + pbonecontroller[j].start; + } + else + { + 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 ) diff --git a/engine/common/system.h b/engine/common/system.h index 79f31935..ee9755c9 100644 --- a/engine/common/system.h +++ b/engine/common/system.h @@ -68,7 +68,7 @@ void Sys_Print( const char *pMsg ); void Sys_PrintLog( const char *pMsg ); void Sys_InitLog( void ); void Sys_CloseLog( void ); -void Sys_Quit( void ); +void Sys_Quit( void ) NORETURN; // // sys_con.c diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 87289d65..b778294d 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -1296,7 +1296,7 @@ void pfnSetModel( edict_t *e, const char *m ) char name[MAX_QPATH]; qboolean found = false; model_t *mod; - int i; + int i = 1; if( !SV_IsValidEdict( e )) return; @@ -1308,7 +1308,7 @@ void pfnSetModel( edict_t *e, const char *m ) if( COM_CheckString( name )) { // 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 )) { diff --git a/mainui b/mainui index 095661b4..f197117d 160000 --- a/mainui +++ b/mainui @@ -1 +1 @@ -Subproject commit 095661b44b5ef3bff4fe887de92bbe8cfc2fc6fd +Subproject commit f197117dacd1938fe3afca34716e4b7b60b6f837 diff --git a/public/crtlib.h b/public/crtlib.h index 5fd83504..f7bbfd90 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -21,8 +21,10 @@ GNU General Public License for more details. #ifdef __GNUC__ #define _format(x) __attribute__((format(printf, x, x+1))) +#define NORETURN __attribute__((noreturn)) #else #define _format(x) +#define NORETURN #endif // timestamp modes diff --git a/ref_gl/gl_alias.c b/ref_gl/gl_alias.c index a1c39cce..d3779b0f 100644 --- a/ref_gl/gl_alias.c +++ b/ref_gl/gl_alias.c @@ -227,7 +227,7 @@ for the model, which holds for all frames */ void BuildTris( void ) { - int len, bestlen, besttype; + int len, bestlen, besttype = 0; int bestverts[1024]; int besttris[1024]; int type, startv; diff --git a/ref_gl/gl_image.c b/ref_gl/gl_image.c index eb8b7a0b..24e92aa9 100644 --- a/ref_gl/gl_image.c +++ b/ref_gl/gl_image.c @@ -481,7 +481,7 @@ static size_t GL_CalcTextureSize( GLenum format, int width, int height, int dept 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 mipcount; @@ -494,7 +494,7 @@ static int GL_CalcMipmapCount( gl_texture_t *tex, qboolean haveBuffer ) // generate mip-levels by user request if( FBitSet( tex->flags, TF_NOMIPMAP )) return 1; - + // mip-maps can't exceeds 16 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 ) { - int maxTextureSize; + int maxTextureSize = 0; int maxDepthSize = 1; 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; maxTextureSize = glConfig.max_3d_texture_size; break; + default: + Assert( false ); } // store original sizes @@ -717,7 +719,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan switch( GL_CalcTextureSamples( channelMask )) { - case 1: + case 1: if( FBitSet( tex->flags, TF_ALPHACONTRAST )) tex->format = GL_INTENSITY8; 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; default: tex->format = GL_RGB; break; } - break; + break; case 4: default: switch( bits ) @@ -1233,7 +1235,7 @@ do specified actions on pixels static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic ) { float emboss_scale = 0.0f; - uint img_flags = 0; + uint img_flags = 0; // force upload texture as RGB or RGBA (detail textures requires this) 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 ); 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 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" ); if( pic ) gEngfuncs.FS_FreeImage( pic ); return 0; - } + } // it's multilayer image! SetBits( pic->flags, IMAGE_MULTILAYER ); @@ -1923,7 +1925,7 @@ void R_InitDlightTexture( void ) return; // already initialized memset( &r_image, 0, sizeof( r_image )); - r_image.width = BLOCK_SIZE; + r_image.width = BLOCK_SIZE; r_image.height = BLOCK_SIZE; r_image.flags = IMAGE_HAS_COLOR; r_image.type = PF_RGBA_32; @@ -2100,7 +2102,7 @@ void R_TextureList_f( void ) case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT24: gEngfuncs.Con_Printf( "DPTH24" ); - break; + break; case GL_DEPTH_COMPONENT32F: gEngfuncs.Con_Printf( "DPTH32" ); break; diff --git a/wscript b/wscript index d67357d9..63e2f4d1 100644 --- a/wscript +++ b/wscript @@ -237,6 +237,7 @@ def configure(conf): '-Werror=bool-compare', '-Werror=bool-operation', '-Werror=uninitialized', + '-Werror=init-self', '-Werror=implicit-fallthrough=2', # clang incompatible without "=2" # '-Wdouble-promotion', # disable warning flood '-Wstrict-aliasing',