From b86150b4b256d13f0ab3bf7aee35c9a13c8ce7d9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 21 Nov 2018 20:43:38 +0800 Subject: [PATCH] erasure-code,test: silence -Wunused-variable warnings GCC 7.3 does not support [[maybe_unused]] very well, so it emits -Wunused-variable warnings even if the variables are marked with maybe_unused. moreover, the C++17 standard does not forbid these warnings: > For an entity marked maybe_unused, implementations are encouraged not to emit a warning that the entity is unused, or that the entity is used despite the presence of the attribute. see also n4659, dcl.attr.unused so, in this change, the warnings are silenced manually. Signed-off-by: Kefu Chai --- src/erasure-code/clay/ErasureCodeClay.cc | 4 ++++ src/test/crimson/test_perfcounters.cc | 1 + 2 files changed, 5 insertions(+) diff --git a/src/erasure-code/clay/ErasureCodeClay.cc b/src/erasure-code/clay/ErasureCodeClay.cc index 9276465edd51..2bf45b72f9de 100644 --- a/src/erasure-code/clay/ErasureCodeClay.cc +++ b/src/erasure-code/clay/ErasureCodeClay.cc @@ -113,6 +113,7 @@ int ErasureCodeClay::decode(const set &want_to_read, set avail; for ([[maybe_unused]] auto& [node, bl] : chunks) { avail.insert(node); + (void)bl; // silence -Wunused-variable } if (is_repair(want_to_read, avail) && @@ -484,6 +485,7 @@ int ErasureCodeClay::repair_one_lost_chunk(map &recovered_data, // check across all erasures and aloof nodes for ([[maybe_unused]] auto& [node, bl] : recovered_data) { if (node % q == z_vec[node / q]) order++; + (void)bl; // silence -Wunused-variable } for (auto node : aloof_nodes) { if (node % q == z_vec[node / q]) order++; @@ -511,6 +513,7 @@ int ErasureCodeClay::repair_one_lost_chunk(map &recovered_data, for ([[maybe_unused]] auto& [node, bl] : recovered_data) { lost_chunk = node; count++; + (void)bl; // silence -Wunused-variable } ceph_assert(count == 1); @@ -655,6 +658,7 @@ int ErasureCodeClay::decode_layered(set &erased_chunks, for (int i = k+nu; (num_erasures < m) && (i < q*t); i++) { if ([[maybe_unused]] auto [it, added] = erased_chunks.emplace(i); added) { num_erasures++; + (void)it; // silence -Wunused-variable } } ceph_assert(num_erasures == m); diff --git a/src/test/crimson/test_perfcounters.cc b/src/test/crimson/test_perfcounters.cc index 581844d133f4..da8cc8f31da6 100644 --- a/src/test/crimson/test_perfcounters.cc +++ b/src/test/crimson/test_perfcounters.cc @@ -36,6 +36,7 @@ static seastar::future<> test_perfcounters(){ if (PERF_VAL != perf_counter_ref.perf_counters->get(PERFTEST_INDEX)) { throw std::runtime_error("perf counter does not match"); } + (void)path; // silence -Wunused-variable } }); }); -- 2.47.3