From 5c1b8cd2215275a95e8ce6bacc45c31b6c7a4c17 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 12 Oct 2020 16:18:06 +0200 Subject: [PATCH] Fix clang-analyzer-deadcode.DeadStores /media/ddnet/src/game/client/components/statboard.cpp:288:3: warning: Value stored to 'tw' is never read [clang-analyzer-deadcode.DeadStores] --- src/base/system.c | 5 ---- src/engine/client/backend_sdl.cpp | 3 +-- src/engine/client/input.cpp | 31 ++++++++++-------------- src/engine/client/text.cpp | 2 -- src/engine/client/video.cpp | 2 +- src/game/client/components/chat.cpp | 1 - src/game/client/components/console.cpp | 1 - src/game/client/components/statboard.cpp | 7 ------ src/game/editor/editor.cpp | 2 -- src/game/editor/popups.cpp | 2 -- src/game/mapbugs.cpp | 3 ++- src/tools/map_convert_07.cpp | 1 - 12 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index 32d73f862..18fd7581c 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -2691,13 +2691,8 @@ int str_utf8_dist_buffer(const char *a_utf8, const char *b_utf8, int *buf, int b dbg_assert(buf_len >= 2 * (a_utf8_len + 1 + b_utf8_len + 1), "buffer too small"); if(a_utf8_len > b_utf8_len) { - int tmp1 = a_utf8_len; const char *tmp2 = a_utf8; - - a_utf8_len = b_utf8_len; a_utf8 = b_utf8; - - b_utf8_len = tmp1; b_utf8 = tmp2; } a = buf; diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 1dc434a64..fff68ef0c 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -3770,7 +3770,6 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand) int MajorV = pCommand->m_pCapabilities->m_ContextMajor; int MinorV = pCommand->m_pCapabilities->m_ContextMinor; - int PatchV = pCommand->m_pCapabilities->m_ContextPatch; *pCommand->m_pInitError = 0; @@ -3786,6 +3785,7 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand) } else if(MinorV == pCommand->m_RequestedMinor) { + int PatchV = pCommand->m_pCapabilities->m_ContextPatch; if(PatchV < pCommand->m_RequestedPatch) { *pCommand->m_pInitError = -2; @@ -3797,7 +3797,6 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand) { MajorV = pCommand->m_RequestedMajor; MinorV = pCommand->m_RequestedMinor; - PatchV = pCommand->m_RequestedPatch; pCommand->m_pCapabilities->m_2DArrayTexturesAsExtension = false; pCommand->m_pCapabilities->m_NPOTTextures = true; diff --git a/src/engine/client/input.cpp b/src/engine/client/input.cpp index 662ca24a0..5eea8e6fd 100644 --- a/src/engine/client/input.cpp +++ b/src/engine/client/input.cpp @@ -227,7 +227,6 @@ int CInput::Update() bool IgnoreKeys = false; while(SDL_PollEvent(&Event)) { - int Key = -1; int Scancode = 0; int Action = IInput::FLAG_PRESS; switch(Event.type) @@ -265,13 +264,11 @@ int CInput::Update() // Sum if you want to ignore multiple modifiers. if(!(Event.key.keysym.mod & g_Config.m_InpIgnoredModifiers)) { - Key = Event.key.keysym.sym; Scancode = Event.key.keysym.scancode; } break; case SDL_KEYUP: Action = IInput::FLAG_RELEASE; - Key = Event.key.keysym.sym; Scancode = Event.key.keysym.scancode; break; @@ -288,37 +285,35 @@ int CInput::Update() // fall through case SDL_MOUSEBUTTONDOWN: if(Event.button.button == SDL_BUTTON_LEFT) - Key = KEY_MOUSE_1; // ignore_convention + Scancode = KEY_MOUSE_1; // ignore_convention if(Event.button.button == SDL_BUTTON_RIGHT) - Key = KEY_MOUSE_2; // ignore_convention + Scancode = KEY_MOUSE_2; // ignore_convention if(Event.button.button == SDL_BUTTON_MIDDLE) - Key = KEY_MOUSE_3; // ignore_convention + Scancode = KEY_MOUSE_3; // ignore_convention if(Event.button.button == SDL_BUTTON_X1) - Key = KEY_MOUSE_4; // ignore_convention + Scancode = KEY_MOUSE_4; // ignore_convention if(Event.button.button == SDL_BUTTON_X2) - Key = KEY_MOUSE_5; // ignore_convention + Scancode = KEY_MOUSE_5; // ignore_convention if(Event.button.button == 6) - Key = KEY_MOUSE_6; // ignore_convention + Scancode = KEY_MOUSE_6; // ignore_convention if(Event.button.button == 7) - Key = KEY_MOUSE_7; // ignore_convention + Scancode = KEY_MOUSE_7; // ignore_convention if(Event.button.button == 8) - Key = KEY_MOUSE_8; // ignore_convention + Scancode = KEY_MOUSE_8; // ignore_convention if(Event.button.button == 9) - Key = KEY_MOUSE_9; // ignore_convention - Scancode = Key; + Scancode = KEY_MOUSE_9; // ignore_convention break; case SDL_MOUSEWHEEL: if(Event.wheel.y > 0) - Key = KEY_MOUSE_WHEEL_UP; // ignore_convention + Scancode = KEY_MOUSE_WHEEL_UP; // ignore_convention if(Event.wheel.y < 0) - Key = KEY_MOUSE_WHEEL_DOWN; // ignore_convention + Scancode = KEY_MOUSE_WHEEL_DOWN; // ignore_convention if(Event.wheel.x > 0) - Key = KEY_MOUSE_WHEEL_LEFT; // ignore_convention + Scancode = KEY_MOUSE_WHEEL_LEFT; // ignore_convention if(Event.wheel.x < 0) - Key = KEY_MOUSE_WHEEL_RIGHT; // ignore_convention + Scancode = KEY_MOUSE_WHEEL_RIGHT; // ignore_convention Action |= IInput::FLAG_RELEASE; - Scancode = Key; break; case SDL_WINDOWEVENT: diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index dc4b83ac6..87e372949 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -1510,8 +1510,6 @@ public: DrawY = TextContainer.m_AlignedStartY; } - DrawX = TextContainer.m_X; - DrawY = TextContainer.m_Y; LineCount = TextContainer.m_LineCount; if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex == -1) diff --git a/src/engine/client/video.cpp b/src/engine/client/video.cpp index 97bf7c2dc..10d391333 100644 --- a/src/engine/client/video.cpp +++ b/src/engine/client/video.cpp @@ -545,7 +545,7 @@ bool CVideo::OpenAudio() av_opt_set_sample_fmt(m_AudioStream.pSwrCtx, "out_sample_fmt", c->sample_fmt, 0); /* initialize the resampling context */ - if((Ret = swr_init(m_AudioStream.pSwrCtx)) < 0) + if(swr_init(m_AudioStream.pSwrCtx) < 0) { dbg_msg("video_recorder", "Failed to initialize the resampling context"); return false; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 1c7a45840..6c09a1945 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -178,7 +178,6 @@ bool CChat::OnInput(IInput::CEvent Event) } int max = minimum(i - Begin + 1, (int)sizeof(Line)); str_utf8_copy(Line, Text + Begin, max); - Begin = i + 1; m_Input.Add(Line); } } diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 245e3d851..8244ac4f0 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -180,7 +180,6 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) } int max = minimum(i - Begin + 1, (int)sizeof(Line)); str_copy(Line, Text + Begin, max); - Begin = i + 1; m_Input.Add(Line); } } diff --git a/src/game/client/components/statboard.cpp b/src/game/client/components/statboard.cpp index e4a5e2d41..fea07d3aa 100644 --- a/src/game/client/components/statboard.cpp +++ b/src/game/client/components/statboard.cpp @@ -244,10 +244,6 @@ void CStatboard::RenderGlobalStats() RenderTools()->DrawSprite(x + px, y + 15, 48 * ScaleX, 48 * ScaleY); Graphics()->QuadsEnd(); } - else - { - px += 40; - } y += 29.0f; @@ -285,7 +281,6 @@ void CStatboard::RenderGlobalStats() char aBuf[128]; CTextCursor Cursor; - tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1, -1.0f); TextRender()->SetCursor(&Cursor, x + 64, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = 220; TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1); @@ -297,7 +292,6 @@ void CStatboard::RenderGlobalStats() str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Frags); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f); TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f); - px += 85; } // DEATHS { @@ -379,7 +373,6 @@ void CStatboard::RenderGlobalStats() str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagCaptures); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f); TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f); - px += 85; } y += LineHeight; } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 2ad519a35..e8fe209e1 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -5633,8 +5633,6 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd if(Input()->KeyPress(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 7940e18ed..13e56962e 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -1474,8 +1474,6 @@ int CEditor::PopupSelectConfigAutoMap(CEditor *pEditor, CUIRect View, void *pCon if(pEditor->Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) s_ScrollValue = clamp(s_ScrollValue + 1.0f / ScrollNum, 0.0f, 1.0f); } - else - ScrollNum = 0; } // Margin for scrollbar diff --git a/src/game/mapbugs.cpp b/src/game/mapbugs.cpp index 8f1e4f99e..64e70620e 100644 --- a/src/game/mapbugs.cpp +++ b/src/game/mapbugs.cpp @@ -27,7 +27,8 @@ static unsigned int BugToFlag(int Bug) { unsigned int Result; dbg_assert((unsigned)Bug < 8 * sizeof(Result), "invalid shift"); - return Result = (1 << Bug); + Result = (1 << Bug); + return Result; } static unsigned int IsBugFlagSet(int Bug, unsigned int BugFlags) diff --git a/src/tools/map_convert_07.cpp b/src/tools/map_convert_07.cpp index 011f3af6d..0c4126eb3 100644 --- a/src/tools/map_convert_07.cpp +++ b/src/tools/map_convert_07.cpp @@ -222,7 +222,6 @@ int main(int argc, const char **argv) int i = 0; for(int Index = 0; Index < g_DataReader.NumItems(); Index++) { - pItem = g_DataReader.GetItem(Index, &Type, &ID); if(Type == MAPITEMTYPE_IMAGE) g_aImageIDs[i++] = Index; }