Skip to content

Commit 16fecc9

Browse files
committed
Fixed several compile warnings
1 parent 117c68f commit 16fecc9

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

engine/render/renderer/platform/vulkan/LogicalDevice.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ LogicalDevice::LogicalDevice(const Surface& surface, PhysicalDevice& physDevice)
8080
GET_UNIQUE_QUEUES(queueCreateInfos, graphicsIdx, presentIdx)
8181

8282
auto deviceExtensions = Vulkan::Config::deviceExtensions;
83-
auto layers = Vulkan::Config::validationLayers;
8483

8584
CREATE_LOGICAL_DEVICE(
8685
vkPhysicalDevice,

engine/render/renderer/platform/vulkan/utils/Device.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <set>
1212

13+
static constexpr uint32_t UNFOUND_DEVICE_ITEM_IDX = -1;
14+
1315
namespace Siege::Vulkan
1416
{
1517
// Device
@@ -47,6 +49,7 @@ uint32_t Device::Physical::GetGraphicsQueue(VkPhysicalDevice device)
4749
}
4850

4951
CC_ASSERT(false, "No Graphics queue found for device!")
52+
return UNFOUND_DEVICE_ITEM_IDX;
5053
}
5154

5255
uint32_t Device::Physical::GetPresentQueue(VkPhysicalDevice device, VkSurfaceKHR surface)
@@ -65,6 +68,7 @@ uint32_t Device::Physical::GetPresentQueue(VkPhysicalDevice device, VkSurfaceKHR
6568
}
6669

6770
CC_ASSERT(false, "No Present queue found for device!")
71+
return UNFOUND_DEVICE_ITEM_IDX;
6872
}
6973

7074
void Device::Physical::GetDevices(VkInstance instance, VkPhysicalDevice* devices)
@@ -270,6 +274,7 @@ uint32_t Device::Physical::FindMemoryType(VkPhysicalDevice device,
270274
}
271275

272276
CC_ASSERT(false, "Failed to find suitable memory type!")
277+
return UNFOUND_DEVICE_ITEM_IDX;
273278
}
274279

275280
VkFormat Device::Physical::FindSupportedFormat(VkPhysicalDevice device,
@@ -295,6 +300,7 @@ VkFormat Device::Physical::FindSupportedFormat(VkPhysicalDevice device,
295300
}
296301
}
297302
CC_ASSERT(false, "Failed to find a supported format!")
303+
return {};
298304
}
299305

300306
bool Device::Physical::HasFormats(VkPhysicalDevice device, VkSurfaceKHR surface)

engine/utils/String.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static char* GetFromFormat(const char* format, T value)
9797
{
9898
size_t len = snprintf(nullptr, 0, format, value);
9999
char* cstr = Allocate(len);
100-
sprintf(cstr, format, value);
100+
snprintf(cstr, len + 1, format, value);
101101
cstr[len] = '\0';
102102
return cstr;
103103
}

engine/utils/String.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ class String
483483
{
484484
const char* data = Data();
485485
size_t formatLen = snprintf(nullptr, 0, data, std::forward<P>(params)...);
486-
char newStr[formatLen];
487-
sprintf(newStr, data, std::forward<P>(params)...);
486+
char newStr[formatLen + 1];
487+
snprintf(newStr, formatLen + 1, data, std::forward<P>(params)...);
488488
Assign(newStr);
489489
}
490490

0 commit comments

Comments
 (0)