From 473f8ca72ece96f0697ca90e4c8ee4a8fb2b7d0a Mon Sep 17 00:00:00 2001 From: phosit Date: Wed, 29 Jan 2025 12:47:21 +0100 Subject: [PATCH] Remove FALLTHROUGH on empty cases `#include "lib/code_annotation.h"` can be removed in some places. --- source/gui/ObjectTypes/CSlider.cpp | 3 +-- source/i18n/L10n.cpp | 4 ++-- source/renderer/VertexArray.cpp | 16 ++++++------- source/renderer/backend/gl/Device.cpp | 22 +++++++++--------- source/renderer/backend/gl/Mapping.cpp | 11 ++++----- source/renderer/backend/gl/ShaderProgram.cpp | 24 ++++++++++---------- source/renderer/backend/gl/Texture.cpp | 9 ++++---- source/renderer/backend/vulkan/Device.cpp | 8 +++---- 8 files changed, 47 insertions(+), 50 deletions(-) diff --git a/source/gui/ObjectTypes/CSlider.cpp b/source/gui/ObjectTypes/CSlider.cpp index dd51f560a7..aad08a0543 100644 --- a/source/gui/ObjectTypes/CSlider.cpp +++ b/source/gui/ObjectTypes/CSlider.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 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 @@ -91,7 +91,6 @@ void CSlider::HandleMessage(SGUIMessage& Message) break; } case GUIM_MOUSE_PRESS_LEFT: - FALLTHROUGH; case GUIM_MOUSE_MOTION: { if (m_Pressed) diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 62907e0451..1de646cb08 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -127,7 +127,7 @@ std::unique_ptr CreateDateTimeInstance(const L10n::DateTimeType return std::unique_ptr{ icu::SimpleDateFormat::createTimeInstance(style, locale)}; - case L10n::DateTime: FALLTHROUGH; + case L10n::DateTime: default: return std::unique_ptr{ icu::SimpleDateFormat::createDateTimeInstance(style, style, locale)}; diff --git a/source/renderer/VertexArray.cpp b/source/renderer/VertexArray.cpp index 273524fc27..a4f0a50f14 100644 --- a/source/renderer/VertexArray.cpp +++ b/source/renderer/VertexArray.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 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 @@ -37,19 +37,19 @@ uint32_t GetAttributeSize(const Renderer::Backend::Format format) { switch (format) { - case Renderer::Backend::Format::R8G8B8A8_UNORM: FALLTHROUGH; + case Renderer::Backend::Format::R8G8B8A8_UNORM: case Renderer::Backend::Format::R8G8B8A8_UINT: return sizeof(u8) * 4; case Renderer::Backend::Format::A8_UNORM: return sizeof(u8); - case Renderer::Backend::Format::R16_UNORM: FALLTHROUGH; - case Renderer::Backend::Format::R16_UINT: FALLTHROUGH; - case Renderer::Backend::Format::R16_SINT: FALLTHROUGH; + case Renderer::Backend::Format::R16_UNORM: + case Renderer::Backend::Format::R16_UINT: + case Renderer::Backend::Format::R16_SINT: case Renderer::Backend::Format::R16_SFLOAT: return sizeof(u16); - case Renderer::Backend::Format::R16G16_UNORM: FALLTHROUGH; - case Renderer::Backend::Format::R16G16_UINT: FALLTHROUGH; - case Renderer::Backend::Format::R16G16_SINT: FALLTHROUGH; + case Renderer::Backend::Format::R16G16_UNORM: + case Renderer::Backend::Format::R16G16_UINT: + case Renderer::Backend::Format::R16G16_SINT: case Renderer::Backend::Format::R16G16_SFLOAT: return sizeof(u16) * 2; case Renderer::Backend::Format::R16G16B16_SFLOAT: diff --git a/source/renderer/backend/gl/Device.cpp b/source/renderer/backend/gl/Device.cpp index b03249fd4c..4bb4ea79af 100644 --- a/source/renderer/backend/gl/Device.cpp +++ b/source/renderer/backend/gl/Device.cpp @@ -1016,21 +1016,21 @@ bool CDevice::IsTextureFormatSupported(const Format format) const case Format::UNDEFINED: break; - case Format::R8G8B8_UNORM: FALLTHROUGH; - case Format::R8G8B8A8_UNORM: FALLTHROUGH; - case Format::A8_UNORM: FALLTHROUGH; + case Format::R8G8B8_UNORM: + case Format::R8G8B8A8_UNORM: + case Format::A8_UNORM: case Format::L8_UNORM: supported = true; break; - case Format::R32_SFLOAT: FALLTHROUGH; - case Format::R32G32_SFLOAT: FALLTHROUGH; - case Format::R32G32B32_SFLOAT: FALLTHROUGH; + case Format::R32_SFLOAT: + case Format::R32G32_SFLOAT: + case Format::R32G32B32_SFLOAT: case Format::R32G32B32A32_SFLOAT: break; - case Format::D16_UNORM: FALLTHROUGH; - case Format::D24_UNORM: FALLTHROUGH; + case Format::D16_UNORM: + case Format::D24_UNORM: case Format::D32_SFLOAT: supported = true; break; @@ -1043,9 +1043,9 @@ bool CDevice::IsTextureFormatSupported(const Format format) const case Format::D32_SFLOAT_S8_UINT: break; - case Format::BC1_RGB_UNORM: FALLTHROUGH; - case Format::BC1_RGBA_UNORM: FALLTHROUGH; - case Format::BC2_UNORM: FALLTHROUGH; + case Format::BC1_RGB_UNORM: + case Format::BC1_RGBA_UNORM: + case Format::BC2_UNORM: case Format::BC3_UNORM: supported = m_Capabilities.S3TC; break; diff --git a/source/renderer/backend/gl/Mapping.cpp b/source/renderer/backend/gl/Mapping.cpp index 841025a0e0..12191abaaf 100644 --- a/source/renderer/backend/gl/Mapping.cpp +++ b/source/renderer/backend/gl/Mapping.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 @@ -19,7 +19,6 @@ #include "Mapping.h" -#include "lib/code_annotation.h" #include "lib/config2.h" namespace Renderer @@ -95,9 +94,9 @@ GLenum FromBlendFactor(const BlendFactor blendFactor) CASE(SRC_ALPHA_SATURATE); #undef CASE // Dual source blending presents only in GL_VERSION >= 3.3. - case BlendFactor::SRC1_COLOR: FALLTHROUGH; - case BlendFactor::ONE_MINUS_SRC1_COLOR: FALLTHROUGH; - case BlendFactor::SRC1_ALPHA: FALLTHROUGH; + case BlendFactor::SRC1_COLOR: + case BlendFactor::ONE_MINUS_SRC1_COLOR: + case BlendFactor::SRC1_ALPHA: case BlendFactor::ONE_MINUS_SRC1_ALPHA: debug_warn("Unsupported blend factor."); break; @@ -117,7 +116,7 @@ GLenum FromBlendOp(const BlendOp blendOp) case BlendOp::MIN: mode = GL_MIN; break; case BlendOp::MAX: mode = GL_MAX; break; #else - case BlendOp::MIN: FALLTHROUGH; + case BlendOp::MIN: case BlendOp::MAX: debug_warn("Unsupported blend op."); break; diff --git a/source/renderer/backend/gl/ShaderProgram.cpp b/source/renderer/backend/gl/ShaderProgram.cpp index ed0d70dd2b..0f66f0ecdb 100644 --- a/source/renderer/backend/gl/ShaderProgram.cpp +++ b/source/renderer/backend/gl/ShaderProgram.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 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 @@ -140,10 +140,10 @@ GLboolean NormalizedFromFormat(const Format format) { switch (format) { - case Format::R8G8_UNORM: FALLTHROUGH; - case Format::R8G8B8_UNORM: FALLTHROUGH; - case Format::R8G8B8A8_UNORM: FALLTHROUGH; - case Format::R16_UNORM: FALLTHROUGH; + case Format::R8G8_UNORM: + case Format::R8G8B8_UNORM: + case Format::R8G8B8A8_UNORM: + case Format::R16_UNORM: case Format::R16G16_UNORM: return GL_TRUE; default: @@ -1660,13 +1660,13 @@ void CShaderProgram::VertexAttribPointer( case VertexAttributeStream::COLOR: ColorPointer(format, stride, static_cast(data) + offset); break; - case VertexAttributeStream::UV0: FALLTHROUGH; - case VertexAttributeStream::UV1: FALLTHROUGH; - case VertexAttributeStream::UV2: FALLTHROUGH; - case VertexAttributeStream::UV3: FALLTHROUGH; - case VertexAttributeStream::UV4: FALLTHROUGH; - case VertexAttributeStream::UV5: FALLTHROUGH; - case VertexAttributeStream::UV6: FALLTHROUGH; + case VertexAttributeStream::UV0: + case VertexAttributeStream::UV1: + case VertexAttributeStream::UV2: + case VertexAttributeStream::UV3: + case VertexAttributeStream::UV4: + case VertexAttributeStream::UV5: + case VertexAttributeStream::UV6: case VertexAttributeStream::UV7: { const int indexOffset = static_cast(stream) - static_cast(VertexAttributeStream::UV0); diff --git a/source/renderer/backend/gl/Texture.cpp b/source/renderer/backend/gl/Texture.cpp index fc91088fcb..fda980b6b0 100644 --- a/source/renderer/backend/gl/Texture.cpp +++ b/source/renderer/backend/gl/Texture.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 @@ -19,7 +19,6 @@ #include "Texture.h" -#include "lib/code_annotation.h" #include "lib/config2.h" #include "renderer/backend/gl/Device.h" #include "renderer/backend/gl/DeviceCommandContext.h" @@ -243,9 +242,9 @@ std::unique_ptr CTexture::Create( pixelType = GL_UNSIGNED_INT_24_8_EXT; break; #endif - case Format::BC1_RGB_UNORM: FALLTHROUGH; - case Format::BC1_RGBA_UNORM: FALLTHROUGH; - case Format::BC2_UNORM: FALLTHROUGH; + case Format::BC1_RGB_UNORM: + case Format::BC1_RGBA_UNORM: + case Format::BC2_UNORM: case Format::BC3_UNORM: compressedFormat = true; break; diff --git a/source/renderer/backend/vulkan/Device.cpp b/source/renderer/backend/vulkan/Device.cpp index df5446a8d4..a6098bbc4c 100644 --- a/source/renderer/backend/vulkan/Device.cpp +++ b/source/renderer/backend/vulkan/Device.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 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 @@ -839,9 +839,9 @@ bool CDevice::IsTextureFormatSupported(const Format format) const case Format::R8G8B8_UNORM: return false; - case Format::BC1_RGB_UNORM: FALLTHROUGH; - case Format::BC1_RGBA_UNORM: FALLTHROUGH; - case Format::BC2_UNORM: FALLTHROUGH; + case Format::BC1_RGB_UNORM: + case Format::BC1_RGBA_UNORM: + case Format::BC2_UNORM: case Format::BC3_UNORM: if (m_Capabilities.S3TC) return true;