Enforce nodiscard

This commit is contained in:
Tony Wasserka 2024-10-20 18:57:45 +02:00
parent 2100cfe3ee
commit 34f134741a
5 changed files with 15 additions and 14 deletions

View file

@ -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)

View file

@ -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<BitsOnBase, ParentClass>, "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<BitsOnBase, ParentClass>, "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<Storage>(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);
}

View file

@ -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<uint64_t>::max());
(void)device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits<uint64_t>::max());
auto [result, next_image_index] = device->acquireNextImageKHR(*swapchain, std::numeric_limits<uint64_t>::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<uint64_t>::max());
(void)device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits<uint64_t>::max());
device->waitIdle();
auto data = reinterpret_cast<char*>(device->mapMemory(*current_frame->framedump_memory, 0, 400 * 240 * 4 * FrameData::num_screen_ids));

View file

@ -91,7 +91,7 @@ inline bool TryAccess(std::weak_ptr<WrappedAttachInfo> 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<std::mutex>(attach_info_shared->condvar_mutex);
std::lock_guard<std::mutex> lock(attach_info_shared->condvar_mutex);
attach_info_shared->request_continue.notify_all();
return true;
}

View file

@ -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<uint64_t>::max());
(void)device.waitForFences({ *completion_fence }, true, std::numeric_limits<uint64_t>::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);