Skip to content

Commit c1e8c1a

Browse files
committed
clang-tidy: Fix bugprone-move-forwarding-reference errors
Reported by Sjors Provoost <[email protected]> bitcoin/bitcoin#31802 (comment) /ci_container_base/include/mp/proxy-io.h:252:16: error: forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference,-warnings-as-errors] /ci_container_base/include/mp/proxy-io.h:336:18: error: forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference,-warnings-as-errors] /ci_container_base/include/mp/util.h:186:12: error: forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference,-warnings-as-errors] https://cirrus-ci.com/task/6187773452877824?logs=ci#L4712
1 parent 0d8012f commit c1e8c1a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/mp/proxy-io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ struct Waiter
249249
{
250250
const std::unique_lock<std::mutex> lock(m_mutex);
251251
assert(!m_fn);
252-
m_fn = std::move(fn);
252+
m_fn = std::forward<Fn>(fn);
253253
m_cv.notify_all();
254254
}
255255

@@ -333,7 +333,7 @@ class Connection
333333
// to the EventLoop TaskSet to avoid "Promise callback destroyed itself"
334334
// error in cases where f deletes this Connection object.
335335
m_on_disconnect.add(m_network.onDisconnect().then(
336-
[f = std::move(f), this]() mutable { m_loop.m_task_set->add(kj::evalLater(kj::mv(f))); }));
336+
[f = std::forward<F>(f), this]() mutable { m_loop.m_task_set->add(kj::evalLater(kj::mv(f))); }));
337337
}
338338

339339
EventLoop& m_loop;

include/mp/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ struct AsyncCallable
183183
template <typename Callable>
184184
AsyncCallable<std::remove_reference_t<Callable>> MakeAsyncCallable(Callable&& callable)
185185
{
186-
return std::move(callable);
186+
return std::forward<Callable>(callable);
187187
}
188188

189189
//! Format current thread name as "{exe_name}-{$pid}/{thread_name}-{$tid}".

0 commit comments

Comments
 (0)