Skip to content

Commit 614fbd3

Browse files
Fix a few errors and warnings found by clang-check (#2404)
1 parent ec62e15 commit 614fbd3

8 files changed

Lines changed: 23 additions & 30 deletions

framework/decode/file_processor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ bool FileProcessor::ProcessMetaData(const format::BlockHeader& block_header, for
868868
format::FillMemoryResourceValueCommandHeader header;
869869

870870
success = ReadBytes(&header.thread_id, sizeof(header.thread_id));
871-
success = ReadBytes(&header.resource_value_count, sizeof(header.resource_value_count));
871+
success = success && ReadBytes(&header.resource_value_count, sizeof(header.resource_value_count));
872872

873873
if (success)
874874
{

framework/decode/vulkan_offscreen_swapchain.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@ VkResult VulkanOffscreenSwapchain::SignalSemaphoresFence(const VulkanQueueInfo*
300300
const VkSemaphore* signal_semaphores,
301301
VkFence fence)
302302
{
303-
uint32_t queue_family_index = default_queue_family_index_;
304-
if (queue_info)
305-
{
306-
queue_family_index = queue_info->family_index;
307-
}
308-
309303
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
310304
VkSubmitInfo submit_info = { VK_STRUCTURE_TYPE_SUBMIT_INFO };
311305

framework/decode/vulkan_replay_consumer_base.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6860,8 +6860,6 @@ VkResult VulkanReplayConsumerBase::OverrideCreateShaderModule(
68606860

68616861
// Replace shader in 'override_info'
68626862
std::unique_ptr<char[]> file_code;
6863-
const uint32_t* const orig_code = original_info->pCode;
6864-
const size_t orig_size = original_info->codeSize;
68656863
uint64_t handle_id = *pShaderModule->GetPointer();
68666864
std::string file_name = "sh" + std::to_string(handle_id);
68676865
std::string file_path = util::filepath::Join(options_.replace_shader_dir, file_name);
@@ -8151,7 +8149,9 @@ VulkanReplayConsumerBase::OverrideQueuePresentKHR(PFN_vkQueuePresentKHR
81518149
// If a swapchain was removed, pNext stucts that reference the swapchain need to be modified as well.
81528150
if (!removed_swapchain_indices_.empty())
81538151
{
8154-
const VkBaseInStructure* next = reinterpret_cast<const VkBaseInStructure*>(modified_present_info.pNext);
8152+
VkBaseInStructure* next =
8153+
reinterpret_cast<VkBaseInStructure*>(const_cast<void*>(modified_present_info.pNext));
8154+
VkBaseInStructure* prev = reinterpret_cast<VkBaseInStructure*>(&modified_present_info);
81558155
while (next != nullptr)
81568156
{
81578157
switch (next->sType)
@@ -8178,7 +8178,7 @@ VulkanReplayConsumerBase::OverrideQueuePresentKHR(PFN_vkQueuePresentKHR
81788178
static_cast<uint32_t>(modified_device_masks_.size());
81798179
modified_device_group_present_info.pDeviceMasks = modified_device_masks_.data();
81808180
modified_device_group_present_info.mode = pNext->mode;
8181-
pNext = &modified_device_group_present_info;
8181+
prev->pNext = (const VkBaseInStructure*)&modified_device_group_present_info;
81828182
}
81838183
break;
81848184
}
@@ -8202,7 +8202,7 @@ VulkanReplayConsumerBase::OverrideQueuePresentKHR(PFN_vkQueuePresentKHR
82028202
modified_present_region_info.swapchainCount =
82038203
static_cast<uint32_t>(modified_regions_.size());
82048204
modified_present_region_info.pRegions = modified_regions_.data();
8205-
pNext = &modified_present_region_info;
8205+
prev->pNext = (const VkBaseInStructure*)&modified_present_region_info;
82068206
}
82078207
break;
82088208
}
@@ -8225,15 +8225,16 @@ VulkanReplayConsumerBase::OverrideQueuePresentKHR(PFN_vkQueuePresentKHR
82258225
modified_present_times_info.pNext = pNext->pNext;
82268226
modified_present_times_info.swapchainCount = static_cast<uint32_t>(modified_times_.size());
82278227
modified_present_times_info.pTimes = modified_times_.data();
8228-
pNext = &modified_present_times_info;
8228+
prev->pNext = (const VkBaseInStructure*)&modified_present_times_info;
82298229
}
82308230
break;
82318231
}
82328232
default:
82338233
break;
82348234
}
82358235

8236-
next = reinterpret_cast<const VkBaseInStructure*>(next->pNext);
8236+
prev = next;
8237+
next = const_cast<VkBaseInStructure*>(next->pNext);
82378238
}
82388239
}
82398240

@@ -11191,6 +11192,7 @@ void VulkanReplayConsumerBase::OverrideUpdateDescriptorSets(
1119111192
create_info->codeSize = file_size;
1119211193
GFXRECON_LOG_INFO("Replacement shader found: %s", file_path.c_str());
1119311194
replaced_file_code.emplace_back(std::move(file_code));
11195+
util::platform::FileClose(fp);
1119411196
}
1119511197
}
1119611198
pNext = const_cast<VkBaseInStructure*>(base->pNext);
@@ -11335,8 +11337,6 @@ VkResult VulkanReplayConsumerBase::OverrideCreateComputePipelines(
1133511337
for (size_t i = 0; i < create_info_count; i++)
1133611338
{
1133711339
auto* create_info = &create_infos[i];
11338-
const void* orig_code = create_info->pCode;
11339-
size_t orig_size = create_info->codeSize;
1134011340
uint64_t handle_id = shaders[i];
1134111341
std::string file_name = "sh" + std::to_string(handle_id);
1134211342
std::string file_path = util::filepath::Join(options_.replace_shader_dir, file_name);
@@ -11354,6 +11354,7 @@ VkResult VulkanReplayConsumerBase::OverrideCreateComputePipelines(
1135411354
create_info->codeSize = file_size;
1135511355
GFXRECON_LOG_INFO("Replacement shader found: %s", file_path.c_str());
1135611356
replaced_file_code.emplace_back(std::move(file_code));
11357+
util::platform::FileClose(fp);
1135711358
}
1135811359
}
1135911360

framework/decode/vulkan_resource_tracking_consumer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,14 +813,12 @@ void VulkanResourceTrackingConsumer::CalculateReplayBindingOffsetAndMemoryAlloca
813813
// during trace and update the replay binding offset and then memory allocation size
814814
// accordingly.
815815

816-
VkDeviceSize replay_bind_offset = (*resources)[0]->GetTraceBindOffset();
817-
818816
// loop through the bound resources and update replay resource binding offset
819817
// based on the memory alignment requirement and update memory allocation size
820818
for (size_t i = 0; i < (*resources).size(); i++)
821819
{
822820
// assign replay bind offset to be the same as trace offset first
823-
replay_bind_offset = (*resources)[i]->GetTraceBindOffset();
821+
VkDeviceSize replay_bind_offset = (*resources)[i]->GetTraceBindOffset();
824822

825823
// make sure the assigned replay bind offset have the same alignment count as trace bind offset
826824
// if trace alignment number is valid

framework/decode/vulkan_virtual_swapchain.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ VkResult VulkanVirtualSwapchain::CreateSwapchainKHR(VkResult
5252
HandlePointerDecoder<VkSwapchainKHR>* swapchain,
5353
const graphics::VulkanDeviceTable* device_table)
5454
{
55-
VkDevice device = VK_NULL_HANDLE;
55+
VkDevice device = VK_NULL_HANDLE;
56+
VkPhysicalDevice physical_device = VK_NULL_HANDLE;
5657
VkSurfaceCapabilitiesKHR surfCapabilities{};
5758

5859
if (device_info != nullptr)
5960
{
6061
device = device_info->handle;
62+
physical_device = device_info->parent;
6163
}
62-
device_table_ = device_table;
63-
VkPhysicalDevice physical_device = device_info->parent;
64+
device_table_ = device_table;
6465

6566
VkSwapchainCreateInfoKHR modified_create_info = *create_info;
6667
modified_create_info.imageUsage =

framework/graphics/vulkan_resources_util.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,10 @@ bool GetTexelCoordinatesFromOffset(VkImageType imageType,
422422
VkDeviceSize* current_row_remaining_size_ptr)
423423
{
424424
bool is_texel_block_size = false;
425-
VkDeviceSize texel_size = 0;
425+
VkDeviceSize texel_size;
426426
uint16_t block_width = 0, block_height = 0;
427-
bool result = GetImageTexelSize(format, &texel_size, &is_texel_block_size, &block_width, &block_height);
428427

429-
if (!result)
428+
if (GetImageTexelSize(format, &texel_size, &is_texel_block_size, &block_width, &block_height))
430429
{
431430
// The image format is not supported
432431
return false;
@@ -464,9 +463,9 @@ bool GetTexelCoordinatesFromOffset(VkImageType imageType,
464463
if (z >= extent.depth)
465464
{
466465
// offset_to_subresource_data_start is beyond the range of subresource data. Because current
467-
// Vulakn specification doesn't allow VK_IMAGE_TYPE_3D for array image, so no next array layer
466+
// Vulkan specification doesn't allow VK_IMAGE_TYPE_3D for array image, so no next array layer
468467
// exist;
469-
result = false;
468+
return false;
470469
}
471470
else
472471
{
@@ -586,7 +585,7 @@ bool GetTexelCoordinatesFromOffset(VkImageType imageType,
586585
*current_row_remaining_size_ptr = current_row_remaining_size;
587586
}
588587

589-
return result;
588+
return true;
590589
}
591590

592591
// Get the offset which is relative to the start of subresource data for a location (pointed by texel

framework/util/logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void Log::LogMessage(
150150
bool opened_file = false;
151151
bool write_indent = settings_.use_indent && (settings_.indent > 0);
152152
bool output_to_stderr = false;
153-
FILE* log_file_ptr;
153+
FILE* log_file_ptr = nullptr;
154154

155155
// Log message prefix
156156
const char process_tag[] = "gfxrecon";

framework/util/page_guard_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class PageGuardManager
116116
// shadow_memory is true.
117117
//
118118
// The shadow_memory_handle parameter is an option value that allows the lifetime of the shadow memory allocation to
119-
// be managed externally. Unless opy-on-map is disabled, copies from the mapped_range portion of mapped_memory to
119+
// be managed externally. Unless copy-on-map is disabled, copies from the mapped_range portion of mapped_memory to
120120
// the shadow memory are performed once, the first time that the shadow memory is added for tracking. Copies will
121121
// not be performed if the mapped range is removed from tracking and then added again.
122122
//

0 commit comments

Comments
 (0)