From 5be02743fab7406dadbe5d2f8a8bc06761116950 Mon Sep 17 00:00:00 2001 From: phosit Date: Wed, 21 May 2025 14:55:52 +0200 Subject: [PATCH] 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. --- source/graphics/Unit.cpp | 4 +--- source/lib/sysdep/os/unix/unix.cpp | 6 +----- source/lib/sysdep/os/win/wposix/waio.cpp | 5 ++--- source/ps/ProfileViewer.h | 4 ++-- source/renderer/backend/gl/ShaderProgram.cpp | 7 ++----- source/renderer/backend/vulkan/DeviceCommandContext.cpp | 6 +++--- source/simulation2/components/CCmpVisualActor.cpp | 4 ++-- source/soundmanager/SoundManager.cpp | 7 ++----- source/soundmanager/items/CSoundBase.cpp | 5 ++--- 9 files changed, 17 insertions(+), 31 deletions(-) diff --git a/source/graphics/Unit.cpp b/source/graphics/Unit.cpp index af4c95c0a2..737857c707 100644 --- a/source/graphics/Unit.cpp +++ b/source/graphics/Unit.cpp @@ -53,9 +53,7 @@ CUnit::~CUnit() std::unique_ptr 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 unit{new CUnit(objectManager, actor, id, seed)}; if (!unit->m_Model) diff --git a/source/lib/sysdep/os/unix/unix.cpp b/source/lib/sysdep/os/unix/unix.cpp index af03fc4d26..ecf5f0bf1e 100644 --- a/source/lib/sysdep/os/unix/unix.cpp +++ b/source/lib/sysdep/os/unix/unix.cpp @@ -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. diff --git a/source/lib/sysdep/os/win/wposix/waio.cpp b/source/lib/sysdep/os/win/wposix/waio.cpp index 81c48b211c..5685b05c9e 100644 --- a/source/lib/sysdep/os/win/wposix/waio.cpp +++ b/source/lib/sysdep/os/win/wposix/waio.cpp @@ -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++) { diff --git a/source/ps/ProfileViewer.h b/source/ps/ProfileViewer.h index a62d9d7490..6aa9bc01e6 100644 --- a/source/ps/ProfileViewer.h +++ b/source/ps/ProfileViewer.h @@ -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; } }; diff --git a/source/renderer/backend/gl/ShaderProgram.cpp b/source/renderer/backend/gl/ShaderProgram.cpp index 7e42346f9a..d7bddc00f3 100644 --- a/source/renderer/backend/gl/ShaderProgram.cpp +++ b/source/renderer/backend/gl/ShaderProgram.cpp @@ -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( diff --git a/source/renderer/backend/vulkan/DeviceCommandContext.cpp b/source/renderer/backend/vulkan/DeviceCommandContext.cpp index 89c4bdb000..0854fec56c 100644 --- a/source/renderer/backend/vulkan/DeviceCommandContext.cpp +++ b/source/renderer/backend/vulkan/DeviceCommandContext.cpp @@ -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(); diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp index 6c2d0d0308..1c88c7d443 100644 --- a/source/simulation2/components/CCmpVisualActor.cpp +++ b/source/simulation2/components/CCmpVisualActor.cpp @@ -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) { diff --git a/source/soundmanager/SoundManager.cpp b/source/soundmanager/SoundManager.cpp index 7d1a5c3c45..98d776a24f 100644 --- a/source/soundmanager/SoundManager.cpp +++ b/source/soundmanager/SoundManager.cpp @@ -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); diff --git a/source/soundmanager/items/CSoundBase.cpp b/source/soundmanager/items/CSoundBase.cpp index 938f028199..24826ff5ec 100644 --- a/source/soundmanager/items/CSoundBase.cpp +++ b/source/soundmanager/items/CSoundBase.cpp @@ -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()