maint: fixes warnings (#3993)

This commit is contained in:
Klaim (Joël Lamotte) 2025-06-24 19:57:26 +02:00 committed by GitHub
parent 98b48779e8
commit a698b17ba9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 16 deletions

View File

@ -105,9 +105,13 @@ namespace mamba::solver
else
{
func(itm);
return util::LoopControl::Continue;
}
}
return util::LoopControl::Continue;
else
{
return util::LoopControl::Continue;
}
},
unknown_job
);

View File

@ -343,7 +343,7 @@ namespace mamba::util
{
// TODO(C++20): After allocating tokens and depths here, call an impl function using
// std::span defined in .cpp
static constexpr auto npos = std::string_view::npos;
static constexpr auto sv_npos = std::string_view::npos;
const auto tokens = detail_parsers::concat_array<char>(open, close);
const auto tokens_str = std::string_view(tokens.data(), tokens.size());
@ -351,13 +351,13 @@ namespace mamba::util
auto depths = std::array<int, P + 1>{}; // Plus one for branchless depths code
const auto start = searcher.find_first(text, tokens_str);
if (start == npos)
if (start == sv_npos)
{
return { npos, npos };
return { sv_npos, sv_npos };
}
auto pos = start;
while (pos != npos)
while (pos != sv_npos)
{
// Change depth of corresponding open/close pair, writing in index P for
// the one not matching.
@ -390,7 +390,7 @@ namespace mamba::util
}
err = ParseError::InvalidInput;
return { start, npos };
return { start, sv_npos };
}
template <std::size_t P, typename Str, typename Searcher>
@ -405,12 +405,12 @@ namespace mamba::util
{
// TODO(C++20): After allocating tokens and depths here, call an impl function using
// std::span defined in .cpp
static constexpr auto npos = std::string_view::npos;
static constexpr auto sv_npos = std::string_view::npos;
if (detail_parsers::empty(val))
{
err = ParseError::InvalidInput;
return npos;
return sv_npos;
}
const auto tokens = detail_parsers::concat_array<char>(
@ -421,9 +421,9 @@ namespace mamba::util
const auto tokens_str = std::string_view(tokens.data(), tokens.size());
auto depths = std::array<int, P + 1>{}; // last for easy branchless access
auto first_val_pos = npos;
auto first_val_pos = sv_npos;
auto pos = searcher.find_first(text, tokens_str);
while (pos != npos)
while (pos != sv_npos)
{
const auto open_pos = detail_parsers::find(open, text[pos]);
const auto close_pos = detail_parsers::find(close, text[pos]);
@ -441,7 +441,7 @@ namespace mamba::util
err = if_else(d < 0, ParseError::InvalidInput, err);
}
const bool match = starts_with(text.substr(pos), val);
first_val_pos = if_else(match && (pos == npos), pos, first_val_pos);
first_val_pos = if_else(match && (pos == sv_npos), pos, first_val_pos);
if (match && (depths == decltype(depths){}))
{
return pos;
@ -454,7 +454,7 @@ namespace mamba::util
err = ParseError::InvalidInput;
return first_val_pos;
}
return npos; // not found
return sv_npos; // not found
}
}

View File

@ -89,7 +89,14 @@ namespace mamba::util
}
assert(utf8_text.size() <= std::numeric_limits<int>::max());
const int size = ::MultiByteToWideChar(CP_UTF8, 0, utf8_text.data(), utf8_text.size(), nullptr, 0);
const int size = ::MultiByteToWideChar(
CP_UTF8,
0,
utf8_text.data(),
static_cast<int>(utf8_text.size()),
nullptr,
0
);
if (size <= 0)
{
throw std::runtime_error(fmt::format(
@ -100,13 +107,14 @@ namespace mamba::util
}
auto output = std::wstring(static_cast<std::size_t>(size), char(0));
assert(output.size() <= std::numeric_limits<int>::max());
[[maybe_unused]] const int res_size = ::MultiByteToWideChar(
CP_UTF8,
0,
utf8_text.data(),
utf8_text.size(),
static_cast<int>(utf8_text.size()),
output.data(),
output.size()
static_cast<int>(output.size())
);
assert(res_size == size);
return output;

View File

@ -73,7 +73,7 @@ namespace
template <typename From, typename To>
void check_exact_num_cast_overflow()
{
static constexpr auto from_lowest = std::numeric_limits<From>::lowest();
auto from_lowest = std::numeric_limits<From>::lowest();
REQUIRE_THROWS_AS(safe_num_cast<To>(from_lowest), std::overflow_error);
}