Skip to content

Commit

Permalink
vkcubepp: Remove implicit casts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gnoliyil authored and charles-lunarg committed Feb 18, 2025
1 parent b4061db commit 8a7c276
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(std::tolower(c));
}
WsiPlatform selection = wsi_from_string(selection_input);
if (selection == WsiPlatform::invalid) {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 8a7c276

Please sign in to comment.