From 4c282bdbb495d034a7eaae2c2e8cb9777e2aa88c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 1 Jul 2023 10:22:15 -0500 Subject: [PATCH] fix: recent build warnings and errors (#5711) * fix: use std::empty instead of isEmpty() * fix: fix trivially assignable warning hicpp-move-const-arg * fix: fix clang-diagnostic-unused-but-set-variable warning * fix: fix readability-braces-around-statements warning --- libtransmission/inout.cc | 2 +- qt/FileTreeItem.cc | 2 ++ qt/FileTreeView.cc | 2 +- qt/RpcQueue.cc | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libtransmission/inout.cc b/libtransmission/inout.cc index 80d2acad7..f536ac0d9 100644 --- a/libtransmission/inout.cc +++ b/libtransmission/inout.cc @@ -249,7 +249,7 @@ std::optional recalculateHash(tr_torrent* tor, tr_piece_index_ auto& cache = tor->session->cache; auto const [begin_byte, end_byte] = tor->block_info().byte_span_for_piece(piece); auto const [begin_block, end_block] = tor->block_span_for_piece(piece); - auto n_bytes_checked = size_t{}; + [[maybe_unused]] auto n_bytes_checked = size_t{}; for (auto block = begin_block; block < end_block; ++block) { auto const block_loc = tor->block_loc(block); diff --git a/qt/FileTreeItem.cc b/qt/FileTreeItem.cc index 65f4e196c..8eab9f2be 100644 --- a/qt/FileTreeItem.cc +++ b/qt/FileTreeItem.cc @@ -22,7 +22,9 @@ std::unordered_map const& FileTreeItem::getMyChildRows() const { // ensure that all the rows are hashed for (int const n = childCount(); first_unhashed_row_ < n; ++first_unhashed_row_) + { child_rows_.emplace(children_[first_unhashed_row_]->name(), first_unhashed_row_); + } return child_rows_; } diff --git a/qt/FileTreeView.cc b/qt/FileTreeView.cc index 3324a7e33..461ade865 100644 --- a/qt/FileTreeView.cc +++ b/qt/FileTreeView.cc @@ -269,7 +269,7 @@ void FileTreeView::onlyCheckSelectedItems() while (!std::empty(parents_queue)) { - auto const parent_index = std::move(parents_queue.front()); + auto const parent_index = parents_queue.front(); parents_queue.pop(); if (std::binary_search(wanted_indices.begin(), wanted_indices.end(), parent_index)) diff --git a/qt/RpcQueue.cc b/qt/RpcQueue.cc index bf872b8fb..daa1c8ac0 100644 --- a/qt/RpcQueue.cc +++ b/qt/RpcQueue.cc @@ -48,7 +48,7 @@ void RpcQueue::stepFinished() else { assert(!next_error_handler_); - assert(queue_.isEmpty()); + assert(std::empty(queue_)); // one way or another, the last step returned nothing. // assume it is OK and ensure that we're not going to give an empty response object to any of the next steps. @@ -61,7 +61,7 @@ void RpcQueue::stepFinished() void RpcQueue::runNext(RpcResponseFuture const& response) { - assert(!queue_.isEmpty()); + assert(!std::empty(queue_)); auto next = std::move(queue_.front()); queue_.pop();