mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
fixed all the errors that the clang static analayzer found
This commit is contained in:
parent
98042012a6
commit
1711be955b
|
@ -80,7 +80,7 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg)
|
|||
|
||||
void dbg_break()
|
||||
{
|
||||
*((unsigned*)0) = 0x0;
|
||||
*((volatile unsigned*)0) = 0x0;
|
||||
}
|
||||
|
||||
void dbg_msg(const char *sys, const char *fmt, ...)
|
||||
|
@ -166,6 +166,8 @@ void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned al
|
|||
MEMTAIL *tail;
|
||||
MEMHEADER *header = (struct MEMHEADER *)malloc(size+sizeof(MEMHEADER)+sizeof(MEMTAIL));
|
||||
dbg_assert(header != 0, "mem_alloc failure");
|
||||
if(!header)
|
||||
return NULL;
|
||||
tail = (struct MEMTAIL *)(((char*)(header+1))+size);
|
||||
header->size = size;
|
||||
header->filename = filename;
|
||||
|
|
|
@ -33,6 +33,13 @@ void dbg_assert(int test, const char *msg);
|
|||
#define dbg_assert(test,msg) dbg_assert_imp(__FILE__, __LINE__, test, msg)
|
||||
void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
|
||||
|
||||
|
||||
#ifdef __clang_analyzer__
|
||||
#include <assert.h>
|
||||
#undef dbg_assert
|
||||
#define dbg_assert(test,msg) assert(test)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Function: dbg_break
|
||||
Breaks into the debugger.
|
||||
|
|
|
@ -1310,7 +1310,6 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
|||
}
|
||||
|
||||
// unpack delta
|
||||
PurgeTick = DeltaTick;
|
||||
SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize);
|
||||
if(SnapSize < 0)
|
||||
{
|
||||
|
@ -1349,7 +1348,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
|||
if(m_aSnapshots[SNAP_PREV] && m_aSnapshots[SNAP_PREV]->m_Tick < PurgeTick)
|
||||
PurgeTick = m_aSnapshots[SNAP_PREV]->m_Tick;
|
||||
if(m_aSnapshots[SNAP_CURRENT] && m_aSnapshots[SNAP_CURRENT]->m_Tick < PurgeTick)
|
||||
PurgeTick = m_aSnapshots[SNAP_PREV]->m_Tick;
|
||||
PurgeTick = m_aSnapshots[SNAP_CURRENT]->m_Tick;
|
||||
m_SnapshotStorage.PurgeUntil(PurgeTick);
|
||||
|
||||
// add new
|
||||
|
|
|
@ -68,7 +68,7 @@ int CConsole::ParseStart(CResult *pResult, const char *pString, int Length)
|
|||
if(Length < Len)
|
||||
Len = Length;
|
||||
|
||||
str_copy(pResult->m_aStringStorage, pString, Length);
|
||||
str_copy(pResult->m_aStringStorage, pString, Len);
|
||||
pStr = pResult->m_aStringStorage;
|
||||
|
||||
// get command
|
||||
|
|
|
@ -195,13 +195,14 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
|
|||
|
||||
// fetch previous indices
|
||||
// we do this as a separate pass because it helps the cache
|
||||
for(i = 0; i < pTo->NumItems(); i++)
|
||||
const int NumItems = pTo->NumItems();
|
||||
for(i = 0; i < NumItems; i++)
|
||||
{
|
||||
pCurItem = pTo->GetItem(i); // O(1) .. O(n)
|
||||
aPastIndecies[i] = GetItemIndexHashed(pCurItem->Key(), Hashlist); // O(n) .. O(n^n)
|
||||
}
|
||||
|
||||
for(i = 0; i < pTo->NumItems(); i++)
|
||||
for(i = 0; i < NumItems; i++)
|
||||
{
|
||||
// do delta
|
||||
ItemSize = pTo->GetItemSize(i); // O(1) .. O(n)
|
||||
|
@ -474,7 +475,7 @@ int CSnapshotStorage::Get(int Tick, int64 *pTagtime, CSnapshot **ppData, CSnapsh
|
|||
if(ppData)
|
||||
*ppData = pHolder->m_pSnap;
|
||||
if(ppAltData)
|
||||
*ppData = pHolder->m_pAltSnap;
|
||||
*ppAltData = pHolder->m_pAltSnap;
|
||||
return pHolder->m_SnapSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -2292,8 +2292,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
s_ScrollValue = clamp(s_ScrollValue + 1.0f/ScrollNum, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
ScrollNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2615,8 +2613,6 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
s_ScrollValue = clamp(s_ScrollValue + 1.0f/ScrollNum, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
ScrollNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -554,7 +554,6 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
|
|||
{
|
||||
if(pEditor->m_SelectedPoints&(1<<v))
|
||||
{
|
||||
Color = 0;
|
||||
pQuad->m_aColors[v].r = (NewVal>>24)&0xff;
|
||||
pQuad->m_aColors[v].g = (NewVal>>16)&0xff;
|
||||
pQuad->m_aColors[v].b = (NewVal>>8)&0xff;
|
||||
|
|
|
@ -599,9 +599,12 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
|
||||
if(!pRawMsg)
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -940,7 +943,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
{
|
||||
OptionMsg.m_NumOptions = NumOptions;
|
||||
Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID);
|
||||
NumOptions = 0;
|
||||
}
|
||||
|
||||
// send tuning parameters to client
|
||||
|
|
|
@ -281,8 +281,8 @@ void IGameController::CycleMap()
|
|||
pNextMap = pMapRotation;
|
||||
|
||||
// cut out the next map
|
||||
char aBuf[512];
|
||||
for(int i = 0; i < 512; i++)
|
||||
char aBuf[512] = {0};
|
||||
for(int i = 0; i < 511; i++)
|
||||
{
|
||||
aBuf[i] = pNextMap[i];
|
||||
if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0)
|
||||
|
|
Loading…
Reference in a new issue