From 451b5a510e115b450e383007c0d09deccb0d333b Mon Sep 17 00:00:00 2001 From: selsta Date: Tue, 27 Apr 2021 05:21:16 +0200 Subject: [PATCH] clang: fix -Wrange-loop-analysis warnings --- contrib/epee/src/byte_slice.cpp | 4 ++-- src/serialization/json_object.h | 2 +- tests/unit_tests/json_serialization.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/epee/src/byte_slice.cpp b/contrib/epee/src/byte_slice.cpp index 453b63a4c..430853c64 100644 --- a/contrib/epee/src/byte_slice.cpp +++ b/contrib/epee/src/byte_slice.cpp @@ -151,7 +151,7 @@ namespace epee : byte_slice() { std::size_t space_needed = 0; - for (const auto source : sources) + for (const auto& source : sources) space_needed += source.size(); if (space_needed) @@ -160,7 +160,7 @@ namespace epee span out{reinterpret_cast(storage.get() + 1), space_needed}; portion_ = {out.data(), out.size()}; - for (const auto source : sources) + for (const auto& source : sources) { std::memcpy(out.data(), source.data(), source.size()); if (out.remove_prefix(source.size()) < source.size()) diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h index de14c8911..35ea990b3 100644 --- a/src/serialization/json_object.h +++ b/src/serialization/json_object.h @@ -365,7 +365,7 @@ inline typename std::enable_if::value, void>::type t static_assert(!std::is_same::value, "encoding an array of unsigned char is faster as hex"); dest.StartArray(); - for (const auto& t : vec) + for (auto t : vec) toJsonValue(dest, t); dest.EndArray(); } diff --git a/tests/unit_tests/json_serialization.cpp b/tests/unit_tests/json_serialization.cpp index f76199e57..9fa589139 100644 --- a/tests/unit_tests/json_serialization.cpp +++ b/tests/unit_tests/json_serialization.cpp @@ -51,7 +51,7 @@ namespace test if (!cryptonote::find_tx_extra_field_by_type(extra_fields, key_field)) throw std::runtime_error{"invalid transaction"}; - for (auto const& input : boost::adaptors::index(source.vout)) + for (auto const input : boost::adaptors::index(source.vout)) { source_amount += input.value().amount; auto const& key = boost::get(input.value().target);