Skip to content

Commit a698b17

Browse files
authored
maint: fixes warnings (#3993)
1 parent 98b4877 commit a698b17

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

libmamba/include/mamba/solver/request.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ namespace mamba::solver
105105
else
106106
{
107107
func(itm);
108+
return util::LoopControl::Continue;
108109
}
109110
}
110-
return util::LoopControl::Continue;
111+
else
112+
{
113+
return util::LoopControl::Continue;
114+
}
111115
},
112116
unknown_job
113117
);

libmamba/include/mamba/util/parsers.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,21 @@ namespace mamba::util
343343
{
344344
// TODO(C++20): After allocating tokens and depths here, call an impl function using
345345
// std::span defined in .cpp
346-
static constexpr auto npos = std::string_view::npos;
346+
static constexpr auto sv_npos = std::string_view::npos;
347347

348348
const auto tokens = detail_parsers::concat_array<char>(open, close);
349349
const auto tokens_str = std::string_view(tokens.data(), tokens.size());
350350

351351
auto depths = std::array<int, P + 1>{}; // Plus one for branchless depths code
352352

353353
const auto start = searcher.find_first(text, tokens_str);
354-
if (start == npos)
354+
if (start == sv_npos)
355355
{
356-
return { npos, npos };
356+
return { sv_npos, sv_npos };
357357
}
358358

359359
auto pos = start;
360-
while (pos != npos)
360+
while (pos != sv_npos)
361361
{
362362
// Change depth of corresponding open/close pair, writing in index P for
363363
// the one not matching.
@@ -390,7 +390,7 @@ namespace mamba::util
390390
}
391391

392392
err = ParseError::InvalidInput;
393-
return { start, npos };
393+
return { start, sv_npos };
394394
}
395395

396396
template <std::size_t P, typename Str, typename Searcher>
@@ -405,12 +405,12 @@ namespace mamba::util
405405
{
406406
// TODO(C++20): After allocating tokens and depths here, call an impl function using
407407
// std::span defined in .cpp
408-
static constexpr auto npos = std::string_view::npos;
408+
static constexpr auto sv_npos = std::string_view::npos;
409409

410410
if (detail_parsers::empty(val))
411411
{
412412
err = ParseError::InvalidInput;
413-
return npos;
413+
return sv_npos;
414414
}
415415

416416
const auto tokens = detail_parsers::concat_array<char>(
@@ -421,9 +421,9 @@ namespace mamba::util
421421
const auto tokens_str = std::string_view(tokens.data(), tokens.size());
422422

423423
auto depths = std::array<int, P + 1>{}; // last for easy branchless access
424-
auto first_val_pos = npos;
424+
auto first_val_pos = sv_npos;
425425
auto pos = searcher.find_first(text, tokens_str);
426-
while (pos != npos)
426+
while (pos != sv_npos)
427427
{
428428
const auto open_pos = detail_parsers::find(open, text[pos]);
429429
const auto close_pos = detail_parsers::find(close, text[pos]);
@@ -441,7 +441,7 @@ namespace mamba::util
441441
err = if_else(d < 0, ParseError::InvalidInput, err);
442442
}
443443
const bool match = starts_with(text.substr(pos), val);
444-
first_val_pos = if_else(match && (pos == npos), pos, first_val_pos);
444+
first_val_pos = if_else(match && (pos == sv_npos), pos, first_val_pos);
445445
if (match && (depths == decltype(depths){}))
446446
{
447447
return pos;
@@ -454,7 +454,7 @@ namespace mamba::util
454454
err = ParseError::InvalidInput;
455455
return first_val_pos;
456456
}
457-
return npos; // not found
457+
return sv_npos; // not found
458458
}
459459
}
460460

libmamba/src/util/os_win.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ namespace mamba::util
8989
}
9090

9191
assert(utf8_text.size() <= std::numeric_limits<int>::max());
92-
const int size = ::MultiByteToWideChar(CP_UTF8, 0, utf8_text.data(), utf8_text.size(), nullptr, 0);
92+
const int size = ::MultiByteToWideChar(
93+
CP_UTF8,
94+
0,
95+
utf8_text.data(),
96+
static_cast<int>(utf8_text.size()),
97+
nullptr,
98+
0
99+
);
93100
if (size <= 0)
94101
{
95102
throw std::runtime_error(fmt::format(
@@ -100,13 +107,14 @@ namespace mamba::util
100107
}
101108

102109
auto output = std::wstring(static_cast<std::size_t>(size), char(0));
110+
assert(output.size() <= std::numeric_limits<int>::max());
103111
[[maybe_unused]] const int res_size = ::MultiByteToWideChar(
104112
CP_UTF8,
105113
0,
106114
utf8_text.data(),
107-
utf8_text.size(),
115+
static_cast<int>(utf8_text.size()),
108116
output.data(),
109-
output.size()
117+
static_cast<int>(output.size())
110118
);
111119
assert(res_size == size);
112120
return output;

libmamba/tests/src/util/test_cast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace
7373
template <typename From, typename To>
7474
void check_exact_num_cast_overflow()
7575
{
76-
static constexpr auto from_lowest = std::numeric_limits<From>::lowest();
76+
auto from_lowest = std::numeric_limits<From>::lowest();
7777
REQUIRE_THROWS_AS(safe_num_cast<To>(from_lowest), std::overflow_error);
7878
}
7979

0 commit comments

Comments
 (0)