Skip to content

Commit

Permalink
Fix 2 static analysis warnings
Browse files Browse the repository at this point in the history
reply.h: std::move was used where std::forward should be used

Fixes #589

Also made move semantics noexcept in connection_pool

Signed-off-by: Ted Lyngmo <[email protected]>
  • Loading branch information
TedLyngmo committed Sep 10, 2024
1 parent 202b36b commit 99a8cbb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/sw/redis++/connection_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ ConnectionPool::ConnectionPool(SimpleSentinel sentinel,
assert(_sentinel);
}

ConnectionPool::ConnectionPool(ConnectionPool &&that) {
ConnectionPool::ConnectionPool(ConnectionPool &&that) noexcept {
std::lock_guard<std::mutex> lock(that._mutex);

_move(std::move(that));
}

ConnectionPool& ConnectionPool::operator=(ConnectionPool &&that) {
ConnectionPool& ConnectionPool::operator=(ConnectionPool &&that) noexcept {
if (this != &that) {
std::lock(_mutex, that._mutex);
std::lock_guard<std::mutex> lock_this(_mutex, std::adopt_lock);
Expand Down
4 changes: 2 additions & 2 deletions src/sw/redis++/connection_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class ConnectionPool {

ConnectionPool() = default;

ConnectionPool(ConnectionPool &&that);
ConnectionPool& operator=(ConnectionPool &&that);
ConnectionPool(ConnectionPool &&that) noexcept;
ConnectionPool& operator=(ConnectionPool &&that) noexcept;

ConnectionPool(const ConnectionPool &) = delete;
ConnectionPool& operator=(const ConnectionPool &) = delete;
Expand Down
2 changes: 1 addition & 1 deletion src/sw/redis++/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ template <typename T, typename ...Args>
auto parse_variant(redisReply &reply) ->
typename std::enable_if<sizeof...(Args) != 0, Variant<T, Args...>>::type {
auto return_var = [](auto &&arg) {
return Variant<T, Args...>(std::move(arg));
return Variant<T, Args...>(std::forward<decltype(arg)>(arg));
};

try {
Expand Down

0 comments on commit 99a8cbb

Please sign in to comment.