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]
This commit is contained in:
def 2020-10-12 16:18:06 +02:00
parent 7c86dd8e5c
commit 5c1b8cd221
12 changed files with 17 additions and 43 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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:

View file

@ -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)

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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

View file

@ -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)

View file

@ -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;
}