Skip to content

Commit

Permalink
Add various moves as suggested by Coverity
Browse files Browse the repository at this point in the history
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 <frank@lichtenheld.com>
  • Loading branch information
flichtenheld authored and dsommers committed Jan 31, 2024
1 parent 853169a commit eaf9147
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion openvpn/client/cliopthelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openvpn/client/cliproto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion openvpn/common/jsonhelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename TITLE>
Expand Down
4 changes: 2 additions & 2 deletions openvpn/common/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ class OptionList : public std::vector<Option>, public RCCopyable<thread_unsafe_r
extraneous_err(line_num, "option", opt);
untag_open_tag(opt.ref(0));
opt.push_back("");
multiline = opt;
multiline = std::move(opt);
in_multiline = true;
}
else
Expand Down Expand Up @@ -1117,7 +1117,7 @@ class OptionList : public std::vector<Option>, public RCCopyable<thread_unsafe_r
extraneous_err(line_num, "meta option", opt);
untag_open_meta_tag(opt.ref(0));
opt.push_back("");
multiline = opt;
multiline = std::move(opt);
in_multiline = true;
}
else
Expand Down
2 changes: 1 addition & 1 deletion openvpn/crypto/static_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class OpenVPNStaticKey
}
if (in_body || data.size() != KEY_SIZE)
throw static_key_parse_error();
key_data_ = data;
key_data_ = std::move(data);
}

std::string render() const
Expand Down
2 changes: 1 addition & 1 deletion openvpn/netconf/linux/gw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class LinuxGW
if (m < best_metric || best_metric == std::numeric_limits<int>::max())
{
best_metric = m;
dev_ = d;
dev_ = std::move(d);
addr_ = a;
}
}
Expand Down
2 changes: 1 addition & 1 deletion openvpn/options/merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class ProfileMerge
if (OptionList::is_open_tag(opt.ref(0)) && opt.size() == 1)
{
OptionList::untag_open_tag(opt.ref(0));
multiline = opt;
multiline = std::move(opt);
in_multiline = true;
unsigned int flags = 0; // not used
opaque_multiline = is_fileref_directive(multiline.ref(0), flags);
Expand Down
2 changes: 1 addition & 1 deletion openvpn/ssl/psid_cookie_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class PsidCookieImpl : public PsidCookie

virtual void provide_psid_cookie_transport(PsidCookieTransportBase::Ptr pctb) override
{
pctb_ = pctb;
pctb_ = std::move(pctb);
}

#ifndef UNIT_TEST
Expand Down
4 changes: 2 additions & 2 deletions openvpn/tun/linux/client/sitnl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ class SITNL

if (!res->route.defined() && save.ifa_index == res->ifindex)
{
res->route = route;
OPENVPN_LOG_RTNL(__func__ << ": MATCH " << route.to_string() << " ifindex=" << save.ifa_index);
res->route = std::move(route);
OPENVPN_LOG_RTNL(__func__ << ": MATCH " << res->route.to_string() << " ifindex=" << save.ifa_index);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/test_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class FakeAsyncResolvable : public RESOLVABLE
EndpointType ep(openvpn_io::ip::make_address(result.first), result.second);
endpoints.push_back(ep);
}
results_[host + ":" + service] = endpoints;
results_[host + ":" + service] = std::move(endpoints);
}

FakeAsyncResolvable(CTOR_ARGS... args)
Expand Down

0 comments on commit eaf9147

Please sign in to comment.