From 8a7c2760f69a13ca333eea3066f5e29423557be0 Mon Sep 17 00:00:00 2001 From: Yilong Li Date: Sun, 16 Feb 2025 01:25:04 -0800 Subject: vkcubepp: Remove implicit casts 1. std::tolower() returns an `int` value. Implicit converting an `int` to a `char` may trigger compiler warnings (-Wconversion on gcc and clang). This change adds an explicit cast to suppress the implicit conversion warnings. 2. Previously we used `assert(!"....")` to show error messages. This does an implicit conversion from `const char*` to `bool` which triggers compiler warnings (-Wconversion). This change replaces it with `assert(false && "...")` which doesn't trigger the warning. Bug: https://fxbug.dev/378964821 Change-Id: I51be6858db558568619d0d2e6bc01a544d3459e4 --- cube/cube.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cube/cube.cpp') diff --git a/cube/cube.cpp b/cube/cube.cpp index 7d959756..45c3afd0 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -1064,7 +1064,7 @@ void Demo::init(int argc, char **argv) { if ((strcmp(argv[i], "--wsi") == 0) && (i < argc - 1)) { std::string selection_input = argv[i + 1]; for (char &c : selection_input) { - c = std::tolower(c); + c = static_cast(std::tolower(c)); } WsiPlatform selection = wsi_from_string(selection_input); if (selection == WsiPlatform::invalid) { @@ -2689,7 +2689,7 @@ void Demo::prepare_textures() { textures[i].imageLayout, vk::AccessFlagBits::eTransferWrite, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eFragmentShader); } else { - assert(!"No support for R8G8B8A8_SRGB as texture image format"); + assert(false && "No support for R8G8B8A8_SRGB as texture image format"); } auto const samplerInfo = vk::SamplerCreateInfo() -- cgit v1.2.3