Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion neo/d3xp/gamesys/SysCmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,8 @@ static void PrintFloat( float f )
char buf[128];
int i;

for( i = idStr::snPrintf( buf, sizeof( buf ), "%3.2f", f ); i < 7; i++ )
// snPrintf() returns >= 0 here, cast to uint to avoid false positive -Wstringop-overflow
for( i = ( unsigned int )idStr::snPrintf( buf, sizeof( buf ), "%3.2f", f ); i < 7; i++ )
{
buf[i] = ' ';
}
Expand Down
10 changes: 5 additions & 5 deletions neo/idlib/Swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@ class idSwap
// byte swapping pointers is pointless because we should never store pointers on disk
assert( !IsPointer( c ) );

if( sizeof( type ) == 1 )
if constexpr( sizeof( type ) == 1 )
{
}
else if( sizeof( type ) == 2 )
else if constexpr( sizeof( type ) == 2 )
{
byte* b = ( byte* )&c;
SwapBytes( b[0], b[1] );
}
else if( sizeof( type ) == 4 )
else if constexpr( sizeof( type ) == 4 )
{
byte* b = ( byte* )&c;
SwapBytes( b[0], b[3] );
SwapBytes( b[1], b[2] );
}
else if( sizeof( type ) == 8 )
else if constexpr( sizeof( type ) == 8 )
{
byte* b = ( byte* )&c;
SwapBytes( b[0], b[7] );
Expand All @@ -106,7 +106,7 @@ class idSwap
}
else
{
assert( false );
static_assert( sizeof( type ) == 0, "unsupported type size for byte swapping" );
}
}

Expand Down