Skip to content

Commit

Permalink
maint: Address compiler warnings (#3605)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Jerphanion <[email protected]>
  • Loading branch information
mathbunnyru and jjerphan authored Nov 18, 2024
1 parent ccbf795 commit 6654e15
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions libmamba/include/mamba/util/parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ namespace mamba::util
template <typename T, std::size_t N>
constexpr auto find(const std::array<T, N>& arr, const T& val) -> std::size_t
{
auto pos = std::size_t(N);
std::size_t pos = N;
for (std::size_t i = 0; i < N; ++i)
{
const bool found = arr[i] == val;
pos = static_cast<int>(found) * i + (1 - static_cast<int>(found)) * pos;
pos = found ? i : pos;
}
return pos;
}
Expand Down
4 changes: 2 additions & 2 deletions libmamba/src/core/prefix_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ namespace mamba
{
j = nlohmann::json::parse(out);
}
catch (const std::exception& ec)
catch (const std::exception& exc)
{
const auto message = fmt::format(
"failed to parse python command output:\n error: {}\n command ran: {}\n env options:{}\n-> output:\n{}\n\n-> error output:{}",
ec.what(),
exc.what(),
fmt::join(args, " "),
fmt::join(env, " "),
out,
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/progress_bar_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ namespace mamba
{
if (!m_is_spinner)
{
auto seed = static_cast<std::size_t>(
auto seed = static_cast<typename std::default_random_engine::result_type>(
std::chrono::system_clock::now().time_since_epoch().count()
);
std::default_random_engine generator(seed);
Expand Down
9 changes: 8 additions & 1 deletion libmamba/tests/src/validation/test_update_framework_v0_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
//
// The full license is in the file LICENSE, distributed with this software.

// There are several `CHECK_THROWS_AS` expressions in this file.
// Sometimes they call a method marked as `[[nodiscard]]`.
// This causes compiler warnnings.
// This doctest flag is designed specifically to prevent this warning from happening.
// https://github.com/doctest/doctest/blob/master/doc/markdown/configuration.md#doctest_config_void_cast_expressions
#define DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS

#include <map>

#include <doctest/doctest.h>
Expand Down Expand Up @@ -249,7 +256,7 @@ TEST_SUITE("validation::v0_6::RootImpl")
out_file.close();

// "2.sv1.root.json" is not compatible spec version (spec version N)
CHECK_THROWS_AS(v0_6::RootImpl root(p), role_file_error);
CHECK_THROWS_AS(v0_6::RootImpl{ p }, role_file_error);
}

TEST_CASE_FIXTURE(RootImplT_v0_6, "update_from_path")
Expand Down
2 changes: 1 addition & 1 deletion micromamba/src/constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ read_binary_from_stdin_and_write_to_file(fs::u8path& filename)
{
throw std::runtime_error("Reading from stdin failed.");
}
out_stream.write(buffer.data(), len);
out_stream.write(buffer.data(), static_cast<std::streamsize>(len));
}
out_stream.close();
}

0 comments on commit 6654e15

Please sign in to comment.