Fix many high level compiler warnings

* Put initializer values inside brackets.
* Put logical AND conditions within parentheses.
* Put assignments within conditional statements within parentheses.
* Mark unused variables as such to suppress compiler warnings.
* Fix vftable shadow warnings caused by ConVar::CreateInternal (does not implement, only interface. Renamed to yield desired behavior).
* Fix 'never' initialized class members for 'CCVarIteratorInternal'.
* Return values in interface vftables that cannot be pure virtual.
This commit is contained in:
Kawe Mazidjatari 2023-04-08 19:00:28 +02:00
parent a83d5737e7
commit 1d04f837f8
12 changed files with 43 additions and 40 deletions

View File

@ -252,7 +252,7 @@ void QuerySystemInfo()
{
for (int i = 0; ; i++)
{
DISPLAY_DEVICE dd = { sizeof(dd), 0 };
DISPLAY_DEVICE dd = { sizeof(dd), {0} };
BOOL f = EnumDisplayDevices(NULL, i, &dd, EDD_GET_DEVICE_INTERFACE_NAME);
if (!f)
{

View File

@ -174,7 +174,7 @@ void CHostState::FrameUpdate(CHostState* pHostState, double flCurrentTime, float
}
}
} while ((oldState != HostStates_t::HS_RUN || g_pHostState->m_iNextState == HostStates_t::HS_LOAD_GAME && single_frame_shutdown_for_reload->GetBool())
} while ((oldState != HostStates_t::HS_RUN || (g_pHostState->m_iNextState == HostStates_t::HS_LOAD_GAME && single_frame_shutdown_for_reload->GetBool()))
&& oldState != HostStates_t::HS_SHUTDOWN
&& oldState != HostStates_t::HS_RESTART);
}

View File

@ -2353,6 +2353,7 @@ void UnitTestRotateBetween()
}
}
Assert(flMaxError < 0.001f);
NOTE_UNUSED(nMaxError);
}
@ -5142,6 +5143,8 @@ bool Frustum_t::Intersects(Frustum_t& otherFrustum) const
VPlane pPlanesB[FRUSTUM_NUMPLANES];
otherFrustum.GetPlanes(pPlanesB);
NOTE_UNUSED(bResult);
// See if all points in B are on one side of any plane in A
for (int p = 0; p < 6; ++p)
{

View File

@ -19,7 +19,7 @@ abstract_class ICollideable
{
public:
// Gets at the entity handle associated with the collideable
virtual IHandleEntity* GetEntityHandle() {};// = 0;
virtual IHandleEntity* GetEntityHandle() { return nullptr; };// = 0;
// TODO!!!
};

View File

@ -21,13 +21,13 @@ class IServerNetworkable
{
// These functions are handled automatically by the server_class macros and CBaseNetworkable.
public:
virtual CBaseEntity* GetBaseEntity() {}; // Only used by game code.
virtual const char* GetClassName() const {};
virtual CBaseEntity* GetBaseEntity() { return nullptr; }; // Only used by game code.
virtual const char* GetClassName() const { return nullptr; };
protected:
// Should never call delete on this!
virtual ~IServerNetworkable() {}
virtual ServerClass* GetServerClass() {};
virtual ServerClass* GetServerClass() { return nullptr; };
};

View File

@ -309,8 +309,8 @@ protected:
virtual bool IsValid(void) = 0; //2
virtual ConCommandBase* Get(void) = 0; //3
CCvar* const m_pOuter;
CConCommandHash* const m_pHash;
CCvar* const m_pOuter = nullptr;
CConCommandHash* const m_pHash = nullptr;
CConCommandHash::CCommandHashIterator_t m_hashIter;
};
@ -399,7 +399,7 @@ public:
bool SetColorFromString(const char* pszValue);
virtual void ChangeStringValue(const char* pszTempValue) = 0;
virtual void Create(const char* pszName, const char* pszDefaultValue, int nFlags, const char* pszHelpString,
virtual void CreateInternal(const char* pszName, const char* pszDefaultValue, int nFlags, const char* pszHelpString,
bool bMin, float fMin, bool bMax, float fMax, FnChangeCallback_t pCallback, const char* pszUsageString) = 0;
void InstallChangeCallback(FnChangeCallback_t callback, bool bInvoke);

View File

@ -590,7 +590,7 @@ bool IsValidUTF8(char* pszString)
pszString = it + 2;
if (c >= 0xE0u)
{
int n = *pszString & 0x3F | ((s & 0x3F | ((c & 0xF) << 6)) << 6);
int n = (*pszString & 0x3F) | (((s & 0x3F) | ((c & 0xF) << 6)) << 6);
if ((*pszString & 0xC0) != 0x80)
{
return false;
@ -599,7 +599,7 @@ bool IsValidUTF8(char* pszString)
pszString = it + 3;
if (c >= 0xF0u)
{
if ((*pszString & 0xC0) != 0x80 || ((n << 6) | *pszString & 0x3Fu) > 0x10FFFF)
if ((*pszString & 0xC0) != 0x80 || ((n << 6) | (*pszString & 0x3Fu)) > 0x10FFFF)
{
return false;
}
@ -776,8 +776,8 @@ vector<string> StringSplit(string svInput, char cDelim, size_t nMax)
for (size_t i = 0; i < svInput.size(); i++)
{
if (i != (svInput.size() - 1) &&
vSubStrings.size() >= nMax || svInput[i] != cDelim)
if ((i != (svInput.size() - 1) && vSubStrings.size() >= nMax)
|| svInput[i] != cDelim)
{
svSubString += svInput[i];
}

View File

@ -107,7 +107,7 @@ uint64_t __fastcall RTech::DecompressPakFileInit(RPakDecompState_t* state, uint8
decompressed_size_bits = byte_init & 0x3F;
byte_init >>= 6;
state->m_nInputBytePos = input_byte_pos_init;
state->m_nDecompSize = byte_init & ((1i64 << decompressed_size_bits) - 1) | (1i64 << decompressed_size_bits);
state->m_nDecompSize = (byte_init & ((1i64 << decompressed_size_bits) - 1)) | (1i64 << decompressed_size_bits);
byte_1_low = *(uint64_t*)((mask & input_byte_pos_init) + file_buf) << (64
- ((uint8_t)decompressed_size_bits
+ 6));

View File

@ -73,7 +73,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
}
// Always show script errors.
bool bLogLevelOverride = (g_bSQAuxError || g_bSQAuxBadLogic && v == g_pErrorVM);
bool bLogLevelOverride = (g_bSQAuxError || (g_bSQAuxBadLogic && v == g_pErrorVM));
LogType_t type = bLogLevelOverride ? LogType_t::SQ_WARNING : LogType_t::SQ_INFO;
va_list args;

View File

@ -147,8 +147,8 @@ unsigned FASTCALL HashInt(const int n)
/*register*/ unsigned even, odd;
odd = g_nRandomValues[(((unsigned)n >> 8) & 0xff)];
even = g_nRandomValues[odd ^ ((unsigned)n >> 24)];
odd = g_nRandomValues[even ^ ((unsigned)n >> 16) & 0xff];
even = g_nRandomValues[odd ^ ((unsigned)n >> 8) & 0xff];
odd = g_nRandomValues[even ^ (((unsigned)n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ (((unsigned)n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ ((unsigned)n & 0xff)];
return (even << 8) | odd;
@ -166,8 +166,8 @@ unsigned FASTCALL Hash4(const void* pKey)
n = *p;
odd = g_nRandomValues[((n >> 8) & 0xff)];
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
return (even << 8) | odd;
@ -186,14 +186,14 @@ unsigned FASTCALL Hash8(const void* pKey)
n = *p;
odd = g_nRandomValues[((n >> 8) & 0xff)];
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
n = *(p + 1);
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
return (even << 8) | odd;
@ -213,20 +213,20 @@ unsigned FASTCALL Hash12(const void* pKey)
odd = g_nRandomValues[((n >> 8) & 0xff)];
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
n = *(p + 1);
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
n = *(p + 2);
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
return (even << 8) | odd;
@ -246,26 +246,26 @@ unsigned FASTCALL Hash16(const void* pKey)
odd = g_nRandomValues[((n >> 8) & 0xff)];
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
n = *(p + 1);
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
n = *(p + 2);
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
n = *(p + 3);
even = g_nRandomValues[odd ^ (n >> 24)];
odd = g_nRandomValues[even ^ (n >> 16) & 0xff];
even = g_nRandomValues[odd ^ (n >> 8) & 0xff];
odd = g_nRandomValues[even ^ ((n >> 16) & 0xff)];
even = g_nRandomValues[odd ^ ((n >> 8) & 0xff)];
odd = g_nRandomValues[even ^ (n & 0xff)];
return (even << 8) | odd;

View File

@ -1018,7 +1018,7 @@ int64 CUtlBuffer::VaScanf(const char* pFmt, va_list list)
int64 numScanned = 0;
char c;
while (c = *pFmt++)
while ((c = *pFmt++))
{
// Stop if we hit the end of the buffer
if (m_Get >= TellMaxPut())

View File

@ -111,8 +111,8 @@ void GenerateLineStripIndexBuffer(unsigned short* pIndices, int nIndexCount, int
baseVertex = nFirstVertex;
for (i = 0; i < numLines; ++i)
{
pIndices[0] = (unsigned short)(nFirstVertex + i);
pIndices[1] = (unsigned short)(nFirstVertex + i + 1);
pIndices[0] = (unsigned short)(baseVertex + i);
pIndices[1] = (unsigned short)(baseVertex + i + 1);
pIndices += 2;
}
}