From 22d8c6e5f4c42882f6d84caf0f71cdb5ed07f691 Mon Sep 17 00:00:00 2001 From: Sam Yates Date: Fri, 8 Dec 2023 11:49:21 +1030 Subject: [PATCH] Fix a few integer type mismatches in for loops. * Use size_t to iterate size_t-bounded loops in `internal_hash()`. * Use unsigned to iterate unsigned-bounded loops in `test_probe.cpp`. --- arbor/include/arbor/util/hash_def.hpp | 4 ++-- test/unit/test_probe.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arbor/include/arbor/util/hash_def.hpp b/arbor/include/arbor/util/hash_def.hpp index 933a3237e2..261e112948 100644 --- a/arbor/include/arbor/util/hash_def.hpp +++ b/arbor/include/arbor/util/hash_def.hpp @@ -55,7 +55,7 @@ inline constexpr std::size_t internal_hash(T&& data) { if constexpr (std::is_integral_v) { unsigned long long bytes = data; std::size_t hash = offset_basis; - for (int ix = 0; ix < sizeof(data); ++ix) { + for (std::size_t ix = 0; ix < sizeof(data); ++ix) { uint8_t byte = bytes & 255; bytes >>= 8; hash = hash ^ byte; @@ -66,7 +66,7 @@ inline constexpr std::size_t internal_hash(T&& data) { if constexpr (std::is_pointer_v) { unsigned long long bytes = reinterpret_cast(data); std::size_t hash = offset_basis; - for (int ix = 0; ix < sizeof(data); ++ix) { + for (std::size_t ix = 0; ix < sizeof(data); ++ix) { uint8_t byte = bytes & 255; bytes >>= 8; hash = hash ^ byte; diff --git a/test/unit/test_probe.cpp b/test/unit/test_probe.cpp index 90771c9800..fc87b1cd43 100644 --- a/test/unit/test_probe.cpp +++ b/test/unit/test_probe.cpp @@ -842,7 +842,7 @@ void run_axial_and_ion_current_sampled_probe_test(context ctx) { ASSERT_NE(nullptr, s); auto [s_beg, s_end] = *s; ASSERT_EQ(s_end - s_beg, n_cv); - for (int ix = 0; ix < n_cv; ++ix) i_memb[ix] = *s_beg++; + for (unsigned ix = 0; ix < n_cv; ++ix) i_memb[ix] = *s_beg++; } else if (pm.id.tag == "I-stimulus") { auto m = any_cast(pm.meta); @@ -853,7 +853,7 @@ void run_axial_and_ion_current_sampled_probe_test(context ctx) { ASSERT_NE(nullptr, s); auto [s_beg, s_end] = *s; ASSERT_EQ(s_end - s_beg, n_cv); - for (int ix = 0; ix < n_cv; ++ix) i_stim[ix] = *s_beg++; + for (unsigned ix = 0; ix < n_cv; ++ix) i_stim[ix] = *s_beg++; } else { // Probe id tells us which axial current this is.