engine: fix implicit-fallthrough, uninitialized, enum-conversation compiler diagnostics

This commit is contained in:
Alibek Omarov 2019-12-23 06:48:17 +03:00
parent e424112020
commit e11a08064d
11 changed files with 19 additions and 9 deletions

View File

@ -2152,6 +2152,7 @@ void CL_ThinkParticle( double frametime, particle_t *p )
p->vel[2] -= grav;
break;
}
// intentionally fallthrough
case pt_blob2:
if( p->packedColor == 255 )
{

View File

@ -408,13 +408,13 @@ void S_MixChannel( channel_t *pChannel, void *pData, int outputOffset, int input
if( pSource->channels == 1 )
{
if( pSource->width == 1 )
S_Mix8Mono( pbuf, pvol, (char *)pData, inputOffset, fracRate, outCount, timecompress );
S_Mix8Mono( pbuf, pvol, pData, inputOffset, fracRate, outCount, timecompress );
else S_Mix16Mono( pbuf, pvol, (short *)pData, inputOffset, fracRate, outCount );
}
else
{
if( pSource->width == 1 )
S_Mix8Stereo( pbuf, pvol, (char *)pData, inputOffset, fracRate, outCount );
S_Mix8Stereo( pbuf, pvol, pData, inputOffset, fracRate, outCount );
else S_Mix16Stereo( pbuf, pvol, (short *)pData, inputOffset, fracRate, outCount );
}
}

View File

@ -106,11 +106,13 @@ void Image_DXTGetPixelFormat( dds_t *hdr )
break;
case TYPE_DXT2:
image.flags &= ~IMAGE_HAS_ALPHA; // alpha is already premultiplied by color
// intentionally fallthrough
case TYPE_DXT3:
image.type = PF_DXT3;
break;
case TYPE_DXT4:
image.flags &= ~IMAGE_HAS_ALPHA; // alpha is already premultiplied by color
// intentionally fallthrough
case TYPE_DXT5:
image.type = PF_DXT5;
break;

View File

@ -275,7 +275,7 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
if( anyformat || !Q_stricmp( ext, format->ext ))
{
Q_sprintf( path, format->formatstring, loadname, cmap->type[i].suf, format->ext );
image.hint = cmap->type[i].hint; // side hint
image.hint = (image_hint_t)cmap->type[i].hint; // side hint
f = FS_LoadFile( path, &filesize, false );
if( f && filesize > 0 )

View File

@ -1246,7 +1246,7 @@ qboolean Image_Decompress( const byte *data )
else Image_GetPaletteLMP( image.palette, LUMP_MASKED );
}
else Image_GetPaletteLMP( image.palette, LUMP_NORMAL );
// intentional falltrough
// intentionally fallthrough
case PF_INDEXED_32:
if( !image.d_currentpal ) image.d_currentpal = (uint *)image.palette;
if( !Image_Copy8bitRGBA( fin, fout, image.width * image.height ))

View File

@ -237,6 +237,7 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesi
{
case LUMP_MASKED:
SetBits( image.flags, IMAGE_ONEBIT_ALPHA );
// intentionally fallthrough
case LUMP_GRADIENT:
case LUMP_QUAKE1:
SetBits( image.flags, IMAGE_HAS_ALPHA );

View File

@ -1246,7 +1246,7 @@ void NET_SendPacketEx( netsrc_t sock, size_t length, const void *data, netadr_t
{
int ret;
struct sockaddr addr;
SOCKET net_socket;
SOCKET net_socket = 0;
if( !net.initialized || to.type == NA_LOOPBACK )
{

View File

@ -409,7 +409,8 @@ float SV_Submerged( edict_t *ent )
svs.groupmask = ent->v.groupinfo;
if( SV_PointContents( point ) == CONTENTS_WATER )
return (ent->v.maxs[2] - ent->v.mins[2]);
case 2: // intentionally fallthrough
// intentionally fallthrough
case 2:
bottom = SV_RecursiveWaterLevel( center, ent->v.absmax[2] - center[2], 0.0f, 0 );
return bottom - start;
}

2
mainui

@ -1 +1 @@
Subproject commit 26d671182590086e91cdad6f121a1ebf6e6f6b8e
Subproject commit 095661b44b5ef3bff4fe887de92bbe8cfc2fc6fd

View File

@ -206,7 +206,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
for( i = 0; i < mod->numframes; i++ )
{
frametype_t frametype = pframetype->type;
psprite->frames[i].type = frametype;
psprite->frames[i].type = (spriteframetype_t)frametype;
switch( frametype )
{
@ -858,6 +858,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
{
case kRenderTransAlpha:
pglDepthMask( GL_FALSE );
// fallthrough
case kRenderTransColor:
case kRenderTransTexture:
pglEnable( GL_BLEND );
@ -865,6 +866,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
break;
case kRenderGlow:
pglDisable( GL_DEPTH_TEST );
// fallthrough
case kRenderTransAdd:
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );

View File

@ -236,6 +236,8 @@ def configure(conf):
'-Werror=duplicated-branches', # BEWARE: buggy
'-Werror=bool-compare',
'-Werror=bool-operation',
'-Werror=uninitialized',
'-Werror=implicit-fallthrough=2', # clang incompatible without "=2"
# '-Wdouble-promotion', # disable warning flood
'-Wstrict-aliasing',
]
@ -248,7 +250,8 @@ def configure(conf):
'-Werror=strict-prototypes',
'-Werror=old-style-declaration',
'-Werror=old-style-definition',
'-Werror=declaration-after-statement'
'-Werror=declaration-after-statement',
'-Werror=enum-conversion'
]
linkflags = conf.get_flags_by_type(linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0])