Skip to content

Commit 8dad136

Browse files
committed
Drop StrcmpFixed and call std::strcmp directly
Once it stopped doing length arithmetic the name no longer described it, and the comment spoke to the diff rather than to the code.
1 parent c73591c commit 8dad136

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

‎engine/src/flutter/shell/platform/embedder/tests/embedder_vk_unittests.cc‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,9 @@ VkResult QueueSubmit(VkQueue queue,
5454
fence);
5555
}
5656

57-
// Exact match. The previous form compared N - 1 bytes of a string literal,
58-
// which stops at its last character and so matched any name the literal is a
59-
// prefix of: "vkQueueSubmit" also claimed "vkQueueSubmit2", handing back a
60-
// function with the wrong signature. Both sides are null-terminated, so strcmp
61-
// says what is meant and cannot be off by one.
62-
template <size_t N>
63-
int StrcmpFixed(const char* str1, const char (&str2)[N]) {
64-
return std::strcmp(str1, str2);
65-
}
66-
6757
PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* pName) {
6858
FML_DCHECK(g_vulkan_proc_info.get_device_proc_addr != nullptr);
69-
if (StrcmpFixed(pName, "vkQueueSubmit") == 0) {
59+
if (std::strcmp(pName, "vkQueueSubmit") == 0) {
7060
g_vulkan_proc_info.queue_submit_proc_addr =
7161
reinterpret_cast<decltype(vkQueueSubmit)*>(
7262
g_vulkan_proc_info.get_device_proc_addr(device, pName));
@@ -77,7 +67,7 @@ PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* pName) {
7767

7868
PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* pName) {
7969
FML_DCHECK(g_vulkan_proc_info.get_instance_proc_addr != nullptr);
80-
if (StrcmpFixed(pName, "vkGetDeviceProcAddr") == 0) {
70+
if (std::strcmp(pName, "vkGetDeviceProcAddr") == 0) {
8171
g_vulkan_proc_info.get_device_proc_addr =
8272
reinterpret_cast<decltype(vkGetDeviceProcAddr)*>(
8373
g_vulkan_proc_info.get_instance_proc_addr(instance, pName));
@@ -113,7 +103,7 @@ TEST_F(EmbedderTest, CanSwapOutVulkanCalls) {
113103
context.SetVulkanInstanceProcAddressCallback(
114104
[](void* user_data, FlutterVulkanInstanceHandle instance,
115105
const char* name) -> void* {
116-
if (StrcmpFixed(name, "vkGetInstanceProcAddr") == 0) {
106+
if (std::strcmp(name, "vkGetInstanceProcAddr") == 0) {
117107
g_vulkan_proc_info.get_instance_proc_addr =
118108
reinterpret_cast<decltype(vkGetInstanceProcAddr)*>(
119109
EmbedderTestContextVulkan::InstanceProcAddr(user_data,

0 commit comments

Comments
 (0)