silenced Coverity warnings (Vulkan + one GL)

Most of them are innocent (like suggestion to pass reference instead of
object copy).
This commit is contained in:
Martin Pulec
2023-01-19 09:57:02 +01:00
parent 88df636be9
commit b7ebc2a8bd
5 changed files with 18 additions and 14 deletions

View File

@@ -347,7 +347,7 @@ static void set_gamma(struct state_gl *s);
struct state_gl {
unordered_map<codec_t, GLuint> PHandles;
GLuint PHandle_deint;
GLuint PHandle_deint = 0;
GLuint current_program = 0;
// Framebuffer

View File

@@ -70,7 +70,7 @@ void check_validation_layers(const std::vector<const char*>& required_layers) {
//for (auto& l : layers) puts(l.layerName);
for (const auto& req_layer : required_layers) {
auto layer_equals = [req_layer](auto layer) { return strcmp(req_layer, layer.layerName) == 0; };
auto layer_equals = [req_layer](auto const &layer) { return strcmp(req_layer, layer.layerName) == 0; };
bool found = std::any_of(layers.begin(), layers.end(), layer_equals);
if (!found) {
throw VulkanError{"Layer "s + req_layer + " is not supported."};
@@ -82,7 +82,7 @@ void check_instance_extensions(const std::vector<const char*>& required_extensio
std::vector<vk::ExtensionProperties> extensions = vk::enumerateInstanceExtensionProperties(nullptr);
for (const auto& req_exten : required_extensions) {
auto extension_equals = [req_exten](auto exten) { return strcmp(req_exten, exten.extensionName) == 0; };
auto extension_equals = [req_exten](auto const &exten) { return strcmp(req_exten, exten.extensionName) == 0; };
bool found = std::any_of(extensions.begin(), extensions.end(), extension_equals);
if (!found) {
throw VulkanError{"Instance extension "s + req_exten + " is not supported."};
@@ -96,7 +96,7 @@ bool check_device_extensions(bool propagate_error,
std::vector<vk::ExtensionProperties> extensions = device.enumerateDeviceExtensionProperties(nullptr);
for (const auto& req_exten : required_extensions) {
auto extension_equals = [req_exten](auto exten) { return strcmp(req_exten, exten.extensionName) == 0; };
auto extension_equals = [req_exten](auto const &exten) { return strcmp(req_exten, exten.extensionName) == 0; };
bool found = std::any_of(extensions.begin(), extensions.end(), extension_equals);
if (!found) {
if (propagate_error) {
@@ -239,8 +239,8 @@ vk::PresentModeKHR get_present_mode(vk::PhysicalDevice gpu, vk::SurfaceKHR surfa
return modes[0];
}
void log_gpu_info(vk::PhysicalDeviceProperties gpu_properties, uint32_t vulkan_version){
log_msg(LogLevel::info, "Vulkan uses GPU called: "s + &gpu_properties.deviceName[0]);
void log_gpu_info(vk::PhysicalDeviceProperties const &gpu_properties, uint32_t vulkan_version){
vulkan_log_msg(LogLevel::info, "Vulkan uses GPU called: "s + &gpu_properties.deviceName[0]);
std::string msg = concat(32, std::array{
"Used Vulkan API: "s,
std::to_string(VK_VERSION_MAJOR(vulkan_version)),

View File

@@ -62,8 +62,8 @@ struct VulkanError : public std::runtime_error {
};
struct WindowParameters {
uint32_t width;
uint32_t height;
uint32_t width = 0;
uint32_t height = 0;
constexpr bool operator==(const WindowParameters& other) const {
return width == other.width &&
@@ -91,11 +91,11 @@ namespace vulkan_display_detail {
// todo C++20 - replace with std::format
template<size_t count>
std::string concat(size_t expected_result_size, std::array<std::string, count> strings){
std::string concat(size_t expected_result_size, std::array<std::string, count> const &strings){
std::string result;
result.reserve(expected_result_size);
for(auto sv: strings){
for(auto const &sv: strings){
result+= sv;
}
return result;
@@ -151,7 +151,7 @@ class VulkanContext {
} swapchain_atributes;
std::vector<SwapchainImage> swapchain_images{};
vk::PresentModeKHR preferred_present_mode;
vk::PresentModeKHR preferred_present_mode{};
vulkan_display::WindowParameters window_parameters;
public:

View File

@@ -143,7 +143,12 @@ public:
~VulkanDisplay() noexcept {
if (!destroyed) {
destroy();
try {
destroy();
} catch (vk::SystemError &e) {
std::string err = std::string("~VulkanDisplay vk::SystemError: ") + e.what() + "\n";
vulkan_display_detail::vulkan_log_msg(LogLevel::error, err);
}
}
}

View File

@@ -214,6 +214,7 @@ struct state_vulkan_sdl2 {
state_vulkan_sdl2& operator=(state_vulkan_sdl2&& other) = delete;
~state_vulkan_sdl2() {
delete frame_mappings;
module_done(&mod);
}
};
@@ -849,8 +850,6 @@ void display_sdl2_done(void* state) {
delete s->vulkan;
s->vulkan = nullptr;
delete s->frame_mappings;
s->frame_mappings = nullptr;
delete s->window_callback;
s->window_callback = nullptr;