diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/base/system.c | 4 | ||||
| -rw-r--r-- | src/base/system.h | 7 | ||||
| -rw-r--r-- | src/engine/client/client.cpp | 3 | ||||
| -rw-r--r-- | src/engine/shared/console.cpp | 2 | ||||
| -rw-r--r-- | src/engine/shared/snapshot.cpp | 7 | ||||
| -rw-r--r-- | src/game/editor/editor.cpp | 4 | ||||
| -rw-r--r-- | src/game/editor/popups.cpp | 1 | ||||
| -rw-r--r-- | src/game/server/gamecontext.cpp | 10 | ||||
| -rw-r--r-- | src/game/server/gamecontroller.cpp | 4 |
9 files changed, 24 insertions, 18 deletions
diff --git a/src/base/system.c b/src/base/system.c index a849e807..410cb699 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -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; diff --git a/src/base/system.h b/src/base/system.h index 032cf785..7ba0c0a0 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -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. diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 6d1d8f4f..a88fe3cb 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -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 diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index 3ff3c5b3..399f5323 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -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 diff --git a/src/engine/shared/snapshot.cpp b/src/engine/shared/snapshot.cpp index 9ef8fdc3..1514278b 100644 --- a/src/engine/shared/snapshot.cpp +++ b/src/engine/shared/snapshot.cpp @@ -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; } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index ee26a3f0..7109adca 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -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; } } diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 2382823d..f281c6aa 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -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; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 5d2f22b8..bab48308 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -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 diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 7001ca32..0ee250e8 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -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) |