From: <sv...@op...> - 2025-07-16 20:03:01
|
Author: manx Date: Wed Jul 16 22:02:54 2025 New Revision: 23774 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=23774 Log: [Var] Make clang-format happy. Modified: trunk/OpenMPT/src/mpt/filemode/fd.hpp trunk/OpenMPT/src/mpt/filemode/iostream.hpp trunk/OpenMPT/src/mpt/filemode/stdfile.hpp trunk/OpenMPT/src/mpt/filemode/stdio.hpp Modified: trunk/OpenMPT/src/mpt/filemode/fd.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/filemode/fd.hpp Wed Jul 16 21:45:02 2025 (r23773) +++ trunk/OpenMPT/src/mpt/filemode/fd.hpp Wed Jul 16 22:02:54 2025 (r23774) @@ -39,7 +39,7 @@ template <mpt::filemode::stdio which> class fd_guard { private: - int old_mode; + int old_mode = -1; public: constexpr static int get_fd() { switch (which) { @@ -60,10 +60,11 @@ public: #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif - explicit fd_guard(mpt::filemode::mode new_mode) - : old_mode(-1) { + explicit fd_guard(mpt::filemode::mode new_mode) { + // clang-format on switch (new_mode) { case mpt::filemode::mode::text: old_mode = setmode(get_fd(), O_TEXT); @@ -85,9 +86,11 @@ fd_guard & operator=(fd_guard &&) = delete; #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif ~fd_guard() { + // clang-format on if (old_mode != -1) { old_mode = setmode(get_fd(), old_mode); } @@ -99,7 +102,7 @@ template <mpt::filemode::stdio which> class fd_guard { private: - int old_mode; + int old_mode = -1; public: static int get_fd() { int fd = -1; @@ -122,10 +125,11 @@ public: #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif - explicit fd_guard(mpt::filemode::mode new_mode) - : old_mode(-1) { + explicit fd_guard(mpt::filemode::mode new_mode) { + // clang-format on switch (new_mode) { case mpt::filemode::mode::text: #if defined(UNICODE) && MPT_LIBC_MS_AT_LEAST(MPT_LIBC_MS_VER_UCRT) @@ -151,9 +155,11 @@ fd_guard & operator=(fd_guard &&) = delete; #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif ~fd_guard() { + // clang-format on if (old_mode != -1) { old_mode = _setmode(get_fd(), old_mode); } @@ -184,9 +190,11 @@ public: #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif explicit fd_guard(mpt::filemode::mode /* new_mode */) { + // clang-format on return; } fd_guard(const fd_guard &) = delete; @@ -195,9 +203,11 @@ fd_guard & operator=(fd_guard &&) = delete; #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif ~fd_guard() { + // clang-format on return; } }; Modified: trunk/OpenMPT/src/mpt/filemode/iostream.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/filemode/iostream.hpp Wed Jul 16 21:45:02 2025 (r23773) +++ trunk/OpenMPT/src/mpt/filemode/iostream.hpp Wed Jul 16 22:02:54 2025 (r23774) @@ -67,9 +67,11 @@ public: #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif explicit iostream_guard(mpt::filemode::mode mode) { + // clang-format on guard.emplace(mode); } iostream_guard(const iostream_guard &) = delete; @@ -78,9 +80,11 @@ iostream_guard & operator=(iostream_guard &&) = delete; #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif ~iostream_guard() { + // clang-format on if constexpr (which != mpt::filemode::stdio::input) { get_stream().flush(); } Modified: trunk/OpenMPT/src/mpt/filemode/stdfile.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/filemode/stdfile.hpp Wed Jul 16 21:45:02 2025 (r23773) +++ trunk/OpenMPT/src/mpt/filemode/stdfile.hpp Wed Jul 16 22:02:54 2025 (r23774) @@ -57,9 +57,11 @@ public: #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif explicit FILE_guard(mpt::filemode::mode new_mode) { + // clang-format on std::fflush(get_FILE()); guard.emplace(new_mode); } @@ -69,9 +71,11 @@ FILE_guard & operator=(FILE_guard &&) = delete; #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif ~FILE_guard() { + // clang-format on std::fflush(get_FILE()); guard.reset(); } Modified: trunk/OpenMPT/src/mpt/filemode/stdio.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/filemode/stdio.hpp Wed Jul 16 21:45:02 2025 (r23773) +++ trunk/OpenMPT/src/mpt/filemode/stdio.hpp Wed Jul 16 22:02:54 2025 (r23774) @@ -42,9 +42,11 @@ public: #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif explicit stdio_guard(mpt::filemode::api api, mpt::filemode::mode mode) { + // clang-format on switch (api) { case mpt::filemode::api::iostream: guard.template emplace<mpt::filemode::iostream_guard<which>>(mode); @@ -66,9 +68,11 @@ stdio_guard & operator=(stdio_guard &&) = delete; #if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 1, 0) // work-around bogus -Wmaybe-uninitialized + // clang-format off MPT_ATTR_NOINLINE MPT_DECL_NOINLINE #endif ~stdio_guard() { + // clang-format on guard.template emplace<std::monostate>(); } }; |