From eaf9147fcda5f6e6f8b1ff78c12484d432af1028 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Wed, 10 Jan 2024 18:20:15 +0100 Subject: [PATCH] Add various moves as suggested by Coverity Out of all the suggestions by Coverity I picked the ones that move non-Ptr objects into variables or attributes. Signed-off-by: Frank Lichtenheld --- openvpn/client/cliopthelper.hpp | 2 +- openvpn/client/cliproto.hpp | 2 +- openvpn/common/jsonhelper.hpp | 2 +- openvpn/common/options.hpp | 4 ++-- openvpn/crypto/static_key.hpp | 2 +- openvpn/netconf/linux/gw.hpp | 2 +- openvpn/options/merge.hpp | 2 +- openvpn/ssl/psid_cookie_impl.hpp | 2 +- openvpn/tun/linux/client/sitnl.hpp | 4 ++-- test/unittests/test_helper.hpp | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openvpn/client/cliopthelper.hpp b/openvpn/client/cliopthelper.hpp index 1b9c0249c..743e25843 100644 --- a/openvpn/client/cliopthelper.hpp +++ b/openvpn/client/cliopthelper.hpp @@ -284,7 +284,7 @@ class ParseClientConfig if (options.exists("push-peer-info")) pushPeerInfo_ = true; if (pushPeerInfo_) - peerInfoUV_ = peer_info_uv; + peerInfoUV_ = std::move(peer_info_uv); } // dev name diff --git a/openvpn/client/cliproto.hpp b/openvpn/client/cliproto.hpp index 938dff193..faf167237 100644 --- a/openvpn/client/cliproto.hpp +++ b/openvpn/client/cliproto.hpp @@ -715,7 +715,7 @@ class Session : ProtoContext, else { fatal_ = Error::AUTH_FAILED; - fatal_reason_ = reason; + fatal_reason_ = std::move(reason); log_reason = "AUTH_FAILED"; } if (notify_callback) diff --git a/openvpn/common/jsonhelper.hpp b/openvpn/common/jsonhelper.hpp index 891d30d8e..3a24ac642 100644 --- a/openvpn/common/jsonhelper.hpp +++ b/openvpn/common/jsonhelper.hpp @@ -164,7 +164,7 @@ inline void from_vector(Json::Value &root, const T &vec, const NAME &name) for (auto &e : vec) array.append(e.to_json()); if (array.size()) - root[name] = array; + root[name] = std::move(array); } template diff --git a/openvpn/common/options.hpp b/openvpn/common/options.hpp index 9e53c50f0..65aaefe58 100644 --- a/openvpn/common/options.hpp +++ b/openvpn/common/options.hpp @@ -1049,7 +1049,7 @@ class OptionList : public std::vector