Enable -Wshadow and fix warnings

Change-Id: Ic7eb38108e4819406551ad35a7f896f03efdb091
Signed-off-by: Alex Bates <alex.bates@arm.com>
This commit is contained in:
Alex Bates 2025-12-03 03:38:55 +00:00
parent 0866cfc352
commit 5f9a544b09
6 changed files with 20 additions and 18 deletions

View file

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

View file

@ -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<instance_private_data>(std::move(table), set_loader_data,
enabled_layer_platforms, api_version, allocator);
auto instance_data = allocator.make_unique<instance_private_data>(
std::move(table), set_loader_data, enabled_layer_platforms, instance_api_version, allocator);
if (instance_data == nullptr)
{

View file

@ -201,11 +201,11 @@ T *allocator::create(size_t num_objects, arg_types &&...args) const noexcept
return nullptr;
}
custom_allocator<T> allocator(*this);
custom_allocator<T> 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<T> allocator(*this);
custom_allocator<T> 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);
}
/**

View file

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

View file

@ -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;
}

View file

@ -108,7 +108,7 @@ static std::unique_ptr<T, std::function<void(T *)>> make_proxy_with_queue(T *obj
wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(proxy), queue);
}
auto delete_proxy = [](T *proxy) { wl_proxy_wrapper_destroy(reinterpret_cast<wl_proxy *>(proxy)); };
auto delete_proxy = [](T *wrapped_proxy) { wl_proxy_wrapper_destroy(reinterpret_cast<wl_proxy *>(wrapped_proxy)); };
return std::unique_ptr<T, std::function<void(T *)>>(proxy, delete_proxy);
}