From 34f134741a4bda9d8ca1ae7529f477a1b7538a96 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 20 Oct 2024 18:57:45 +0200 Subject: [PATCH] Enforce nodiscard --- CMakeLists.txt | 1 + source/framework/bit_field_new.hpp | 12 ++++++------ source/gui-sdl/sdl_vulkan_display.hpp | 6 +++--- source/interpreter.h | 2 +- source/video_core/src/video_core/vulkan/renderer.cpp | 8 ++++---- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc73e2e..8f48ad1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) add_compile_options(-Werror=implicit-fallthrough) add_compile_options(-Werror=return-type) +add_compile_options(-Werror=unused-result) # Prefer Conan-provided packages over system ones set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) diff --git a/source/framework/bit_field_new.hpp b/source/framework/bit_field_new.hpp index e182dce..0ac4863 100644 --- a/source/framework/bit_field_new.hpp +++ b/source/framework/bit_field_new.hpp @@ -36,7 +36,7 @@ public: } // Setter: Copies the storage of the parent instance and returns the manipulated value (contained in the new parent instance) - ParentClass Set(Exposure value) const { + [[nodiscard]] ParentClass Set(Exposure value) const { //static_assert(std::is_base_of_v, "Given ParentClass does not inherit BitsOnBase"); static_assert(sizeof(ParentClass) == sizeof(Storage), "ParentClass has additional members other than storage"); @@ -51,7 +51,7 @@ public: } /// Concise version of Set(value) - ParentClass operator ()(Exposure value) const { + [[nodiscard]] ParentClass operator ()(Exposure value) const { return Set(value); } @@ -185,7 +185,7 @@ public: } // Setter: Copies the storage of the parent instance and returns the manipulated value (contained in the new parent instance) - constexpr ParentClass Set(Exposure value) const { + [[nodiscard]] constexpr ParentClass Set(Exposure value) const { //static_assert(std::is_base_of_v, "Given ParentClass does not inherit BitsOnBase"); static_assert(sizeof(ParentClass) == sizeof(Storage), "ParentClass has additional members other than storage"); @@ -206,7 +206,7 @@ public: } /// Concise version of Set(value) - constexpr ParentClass operator ()(Exposure value) const { + [[nodiscard]] constexpr ParentClass operator ()(Exposure value) const { return Set(value); } @@ -249,7 +249,7 @@ public: } // Setter: Copies the storage of the parent instance and returns the manipulated value (contained in the new parent instance) - ParentClass Set(Exposure value) const { + [[nodiscard]] ParentClass Set(Exposure value) const { return MemberLens::modify( *this, [&](const auto& data) { return (data & neg_field_mask) | ((static_cast(value) << Position) & field_mask); }); } @@ -260,7 +260,7 @@ public: } /// Concise version of Set(value) - constexpr ParentClass operator ()(Exposure value) const { + [[nodiscard]] constexpr ParentClass operator ()(Exposure value) const { return Set(value); } diff --git a/source/gui-sdl/sdl_vulkan_display.hpp b/source/gui-sdl/sdl_vulkan_display.hpp index 677bde1..43614da 100644 --- a/source/gui-sdl/sdl_vulkan_display.hpp +++ b/source/gui-sdl/sdl_vulkan_display.hpp @@ -325,7 +325,7 @@ public: // auto this_frame = clock::now(); // TODO: Commit this change! - device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits::max()); + (void)device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits::max()); auto [result, next_image_index] = device->acquireNextImageKHR(*swapchain, std::numeric_limits::max(), *current_frame->image_available_semaphore, vk::Fence { }); if (result != vk::Result::eSuccess && result != vk::Result::eSuboptimalKHR) { @@ -430,7 +430,7 @@ public: 1, &*command_buffer, 1, &*current_frame->render_finished_semaphore }; - graphics_queue.submit(1, &info, *current_frame->render_finished_fence); + (void)graphics_queue.submit(1, &info, *current_frame->render_finished_fence); current_frame->render_finished_fence_awaitable = CPUAwaitable(*current_frame->render_finished_fence); } @@ -464,7 +464,7 @@ public: // std::this_thread::sleep_for(std::chrono::milliseconds { 1000 } / 30); if (new_frame_received[0] || new_frame_received[2]) { // TODO: Hide frame dumping behind setting - device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits::max()); + (void)device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits::max()); device->waitIdle(); auto data = reinterpret_cast(device->mapMemory(*current_frame->framedump_memory, 0, 400 * 240 * 4 * FrameData::num_screen_ids)); diff --git a/source/interpreter.h b/source/interpreter.h index 2c6b4f2..44ef1c3 100644 --- a/source/interpreter.h +++ b/source/interpreter.h @@ -91,7 +91,7 @@ inline bool TryAccess(std::weak_ptr attach_info_weak, std::fu // Drop the original data and signal the main thread to continue // Note that we lock the mutex here purely to make sure we don't signal the condition variable before it is being waited for attach_info_shared->data = nullptr; - std::lock_guard(attach_info_shared->condvar_mutex); + std::lock_guard lock(attach_info_shared->condvar_mutex); attach_info_shared->request_continue.notify_all(); return true; } diff --git a/source/video_core/src/video_core/vulkan/renderer.cpp b/source/video_core/src/video_core/vulkan/renderer.cpp index 8318600..6396b2e 100644 --- a/source/video_core/src/video_core/vulkan/renderer.cpp +++ b/source/video_core/src/video_core/vulkan/renderer.cpp @@ -370,7 +370,7 @@ void Renderer::ProduceFrame(EmuDisplay::EmuDisplay& display, EmuDisplay::Frame& vk::SubmitInfo submit_info { 0, nullptr, &submit_wait_flags, 1, &*command_buffer, 0, nullptr }; { std::unique_lock lock(g_vulkan_queue_mutex); - graphics_queue.submit(1, &submit_info, vk::Fence { }); + (void)graphics_queue.submit(1, &submit_info, vk::Fence { }); } FrameMark; @@ -1367,7 +1367,7 @@ void Renderer::FlushTriangleBatches(Context& context) try { vk::SubmitInfo submit_info { 0, nullptr, &submit_wait_flags, 1, &*batch.command_buffer, 0, nullptr }; std::unique_lock lock(g_vulkan_queue_mutex); - graphics_queue.submit(1, &submit_info, *batch.fence); + (void)graphics_queue.submit(1, &submit_info, *batch.fence); } } catch (std::exception& exc) { printf("EXCEPTION: %s\n", exc.what()); @@ -1420,7 +1420,7 @@ bool Renderer::BlitImage(Context& context, uint32_t /* TODO: PAddr */ input_addr // Wait for blit resources to become available again auto& completion_fence = blit_resources[next_blit_resource].completion_fence; - device.waitForFences({ *completion_fence }, true, std::numeric_limits::max()); + (void)device.waitForFences({ *completion_fence }, true, std::numeric_limits::max()); device.resetFences({ *completion_fence }); auto& [command_buffer, command_buffer2] = blit_resources[next_blit_resource].command_buffers; ++next_blit_resource %= blit_resources.size(); @@ -1500,7 +1500,7 @@ bool Renderer::BlitImage(Context& context, uint32_t /* TODO: PAddr */ input_addr &submit_wait_flags, 1, &*command_buffer, 0, nullptr }; std::unique_lock lock(g_vulkan_queue_mutex); - graphics_queue.submit(1, &submit_info, *completion_fence); + (void)graphics_queue.submit(1, &submit_info, *completion_fence); } resource_manager->InvalidateOverlappingResources(output);