From 5f9a544b096089ceaf2a3a7ba938416fdc598cb1 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Wed, 3 Dec 2025 03:38:55 +0000 Subject: [PATCH] Enable -Wshadow and fix warnings Change-Id: Ic7eb38108e4819406551ad35a7f896f03efdb091 Signed-off-by: Alex Bates --- CMakeLists.txt | 2 ++ layer/private_data.cpp | 16 ++++++++-------- util/custom_allocator.hpp | 10 +++++----- wsi/swapchain_base.cpp | 6 +++--- wsi/wayland/present_id_wayland.cpp | 2 +- wsi/wayland/wl_object_owner.hpp | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ea5063..f32af7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ endif() string(APPEND CMAKE_CXX_FLAGS " -Wall -Werror -Wextra" + " -Wshadow" " -Wdouble-promotion -Wnon-virtual-dtor -Wdelete-non-virtual-dtor" " -Wcast-qual -Werror=return-type -Wmissing-format-attribute" " -pthread -fPIC" @@ -42,6 +43,7 @@ string(APPEND CMAKE_CXX_FLAGS string(APPEND CMAKE_C_FLAGS " -Wall -Werror -Wextra" + " -Wshadow" " -Wstrict-prototypes" " -fPIC" ) diff --git a/layer/private_data.cpp b/layer/private_data.cpp index 94d1365..30464ca 100644 --- a/layer/private_data.cpp +++ b/layer/private_data.cpp @@ -179,12 +179,12 @@ PFN_vkVoidFunction device_dispatch_table::get_user_enabled_entrypoint(VkDevice d } instance_private_data::instance_private_data(instance_dispatch_table table, PFN_vkSetInstanceLoaderData set_loader_data, - util::wsi_platform_set enabled_layer_platforms, const uint32_t api_version, - const util::allocator &alloc) + util::wsi_platform_set layer_platforms, + const uint32_t instance_api_version, const util::allocator &alloc) : disp{ std::move(table) } - , api_version{ api_version } + , api_version{ instance_api_version } , SetInstanceLoaderData{ set_loader_data } - , enabled_layer_platforms{ enabled_layer_platforms } + , enabled_layer_platforms{ layer_platforms } , allocator{ alloc } , surfaces{ alloc } , enabled_extensions{ allocator } @@ -205,11 +205,11 @@ static inline void *get_key(dispatchable_type dispatchable_object) VkResult instance_private_data::associate(VkInstance instance, instance_dispatch_table table, PFN_vkSetInstanceLoaderData set_loader_data, - util::wsi_platform_set enabled_layer_platforms, const uint32_t api_version, - const util::allocator &allocator) + util::wsi_platform_set enabled_layer_platforms, + const uint32_t instance_api_version, const util::allocator &allocator) { - auto instance_data = allocator.make_unique(std::move(table), set_loader_data, - enabled_layer_platforms, api_version, allocator); + auto instance_data = allocator.make_unique( + std::move(table), set_loader_data, enabled_layer_platforms, instance_api_version, allocator); if (instance_data == nullptr) { diff --git a/util/custom_allocator.hpp b/util/custom_allocator.hpp index 1bcc1f7..fe7579e 100644 --- a/util/custom_allocator.hpp +++ b/util/custom_allocator.hpp @@ -201,11 +201,11 @@ T *allocator::create(size_t num_objects, arg_types &&...args) const noexcept return nullptr; } - custom_allocator allocator(*this); + custom_allocator object_allocator(*this); T *ptr; try { - ptr = allocator.allocate(num_objects); + ptr = object_allocator.allocate(num_objects); } catch (...) { @@ -232,7 +232,7 @@ T *allocator::create(size_t num_objects, arg_types &&...args) const noexcept objects_constructed--; ptr[objects_constructed].~T(); } - allocator.deallocate(ptr, num_objects); + object_allocator.deallocate(ptr, num_objects); return nullptr; } return ptr; @@ -247,12 +247,12 @@ void allocator::destroy(size_t num_objects, T *objects) const noexcept return; } - custom_allocator allocator(*this); + custom_allocator object_allocator(*this); for (size_t i = 0; i < num_objects; i++) { objects[i].~T(); } - allocator.deallocate(objects, num_objects); + object_allocator.deallocate(objects, num_objects); } /** diff --git a/wsi/swapchain_base.cpp b/wsi/swapchain_base.cpp index e56173a..5e93310 100644 --- a/wsi/swapchain_base.cpp +++ b/wsi/swapchain_base.cpp @@ -686,11 +686,11 @@ VkResult swapchain_base::queue_present(VkQueue queue, const VkPresentInfoKHR *pr { VkSemaphore present_fence_wait_sem = m_swapchain_images[submit_info.pending_present.image_index].get_present_fence_wait_semaphore(); - const queue_submit_semaphores wait_semaphores = { &present_fence_wait_sem, 1, nullptr, 0 }; + const queue_submit_semaphores present_fence_semaphores = { &present_fence_wait_sem, 1, nullptr, 0 }; /* - * Here we chain wait_semaphores with present_fence through present_fence_wait. + * Here we chain present_fence_semaphores with present_fence through present_fence_wait. */ - TRY(sync_queue_submit(m_device_data, queue, submit_info.present_fence, wait_semaphores)); + TRY(sync_queue_submit(m_device_data, queue, submit_info.present_fence, present_fence_semaphores)); } #if VULKAN_WSI_LAYER_EXPERIMENTAL diff --git a/wsi/wayland/present_id_wayland.cpp b/wsi/wayland/present_id_wayland.cpp index ef5750a..0804da1 100644 --- a/wsi/wayland/present_id_wayland.cpp +++ b/wsi/wayland/present_id_wayland.cpp @@ -62,7 +62,7 @@ uint64_t wsi_ext_present_id_wayland::get_present_id_from_image_index(uint32_t im } auto feedback = m_pending_presents.find( - [image_index](const presentation_feedback &feedback) { return feedback.get_image_index() == image_index; }); + [image_index](const presentation_feedback &candidate) { return candidate.get_image_index() == image_index; }); return feedback != nullptr ? feedback->get_present_id() : 0; } diff --git a/wsi/wayland/wl_object_owner.hpp b/wsi/wayland/wl_object_owner.hpp index b75252c..a3befef 100644 --- a/wsi/wayland/wl_object_owner.hpp +++ b/wsi/wayland/wl_object_owner.hpp @@ -108,7 +108,7 @@ static std::unique_ptr> make_proxy_with_queue(T *obj wl_proxy_set_queue(reinterpret_cast(proxy), queue); } - auto delete_proxy = [](T *proxy) { wl_proxy_wrapper_destroy(reinterpret_cast(proxy)); }; + auto delete_proxy = [](T *wrapped_proxy) { wl_proxy_wrapper_destroy(reinterpret_cast(wrapped_proxy)); }; return std::unique_ptr>(proxy, delete_proxy); }