Don't use UNUSED2 on always unused variables

Not introducing a variable enforces that the variable is not used.
`UNUSED2` on the other hand is used to silence the warning.
This commit is contained in:
phosit
2025-05-21 14:55:52 +02:00
committed by Phosit
parent c0f20171f8
commit 5be02743fa
9 changed files with 17 additions and 31 deletions
+1 -3
View File
@@ -53,9 +53,7 @@ CUnit::~CUnit()
std::unique_ptr<CUnit> CUnit::Create(const CStrW& actorName, const entity_id_t id, const uint32_t seed, CObjectManager& objectManager)
{
auto [success, actor] = objectManager.FindActorDef(actorName);
UNUSED2(success);
const CActorDef& actor{std::get<1>(objectManager.FindActorDef(actorName))};
std::unique_ptr<CUnit> unit{new CUnit(objectManager, actor, id, seed)};
if (!unit->m_Model)
+1 -5
View File
@@ -274,12 +274,8 @@ ErrorReactionInternal sys_display_error(const wchar_t* text, size_t flags)
}
Status sys_StatusDescription(int err, wchar_t* buf, size_t max_chars)
Status sys_StatusDescription(int /*err*/, wchar_t* /*buf*/, size_t /*max_chars*/)
{
UNUSED2(err);
UNUSED2(buf);
UNUSED2(max_chars);
// don't need to do anything: lib/errors.cpp already queries
// libc's strerror(). if we ever end up needing translation of
// e.g. Qt or X errors, that'd go here.
+2 -3
View File
@@ -566,11 +566,10 @@ int aio_write(struct aiocb* cb)
return Issue(cb);
}
int lio_listio(int mode, struct aiocb* const cbs[], int n, struct sigevent* se)
// Signaling is not implemented.
int lio_listio(int mode, struct aiocb* const cbs[], int n, struct sigevent* /*se*/)
{
ENSURE(mode == LIO_WAIT || mode == LIO_NOWAIT);
UNUSED2(se); // signaling is not implemented.
for(int i = 0; i < n; i++)
{
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -119,7 +119,7 @@ public:
*
* @return true if the row should be highlighted in a special color.
*/
virtual bool IsHighlightRow(size_t row) { UNUSED2(row); return false; }
virtual bool IsHighlightRow(size_t /*row*/) { return false; }
};
+2 -5
View File
@@ -675,11 +675,8 @@ public:
m_Program = 0;
m_FileDependencies = {programPath};
for (const auto& [path, type] : shaderStages)
{
UNUSED2(type);
m_FileDependencies.emplace_back(path);
}
for (const auto& shaderStage : shaderStages)
m_FileDependencies.emplace_back(std::get<0>(shaderStage));
// TODO: replace by scoped bind.
m_Device->GetActiveCommandContext()->SetGraphicsPipelineState(
@@ -608,9 +608,9 @@ void CDeviceCommandContext::BeginFramebufferPass(IFramebuffer* framebuffer)
m_Framebuffer->GetDepthStencilAttachmentLoadOp() == AttachmentLoadOp::CLEAR);
if (needsClearValues)
{
for (CTexture* colorAttachment : m_Framebuffer->GetColorAttachments())
const CFramebuffer::ColorAttachments& colorAttachments{m_Framebuffer->GetColorAttachments()};
std::for_each(colorAttachments.begin(), colorAttachments.end(), [&](CTexture*)
{
UNUSED2(colorAttachment);
const CColor& clearColor = m_Framebuffer->GetClearColor();
// The four array elements of the clear color map to R, G, B, and A
// components of image formats, in order.
@@ -619,7 +619,7 @@ void CDeviceCommandContext::BeginFramebufferPass(IFramebuffer* framebuffer)
clearValues.back().color.float32[1] = clearColor.g;
clearValues.back().color.float32[2] = clearColor.b;
clearValues.back().color.float32[3] = clearColor.a;
}
});
if (m_Framebuffer->GetDepthStencilAttachment())
{
clearValues.emplace_back();
@@ -496,12 +496,12 @@ public:
m_Unit->GetAnimation()->SetAnimationSyncOffset(m_AnimSyncOffsetTime.ToFloat());
}
void SetShadingColor(fixed r, fixed g, fixed b, fixed a) override
// TODO: Why is `a` even an argument?
void SetShadingColor(fixed r, fixed g, fixed b, fixed /*a*/) override
{
m_R = r;
m_G = g;
m_B = b;
UNUSED2(a); // TODO: why is this even an argument?
if (m_Unit)
{
+2 -5
View File
@@ -664,23 +664,20 @@ void CSoundManager::PlayAsGroup(const VfsPath& groupPath, const CVector3D& sourc
group->PlayNext(sourcePos, source);
}
void CSoundManager::PlayAsMusic(const VfsPath& itemPath, bool looping)
void CSoundManager::PlayAsMusic(const VfsPath& itemPath, bool /*looping*/)
{
if (m_Enabled)
{
UNUSED2(looping);
ISoundItem* aSnd = LoadItem(itemPath);
if (aSnd != NULL)
SetMusicItem(aSnd);
}
}
void CSoundManager::PlayAsAmbient(const VfsPath& itemPath, bool looping)
void CSoundManager::PlayAsAmbient(const VfsPath& itemPath, bool /*looping*/)
{
if (m_Enabled)
{
UNUSED2(looping);
ISoundItem* aSnd = LoadItem(itemPath);
if (aSnd != NULL)
SetAmbientItem(aSnd);
+2 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -57,9 +57,8 @@ void CSoundBase::ReleaseOpenAL()
}
}
void CSoundBase::Attach(CSoundData* itemData)
void CSoundBase::Attach(CSoundData* /*itemData*/)
{
UNUSED2(itemData);
}
void CSoundBase::ResetVars()