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 <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2018-11-21 20:43:38 +08:00
parent 0a0e9f0179
commit b86150b4b2
2 changed files with 5 additions and 0 deletions

View File

@ -113,6 +113,7 @@ int ErasureCodeClay::decode(const set<int> &want_to_read,
set<int> 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<int, bufferlist> &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<int, bufferlist> &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<int> &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);

View File

@ -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
}
});
});