Skip to content

Commit

Permalink
refactor: fix performance-move-const-arg lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 16, 2024
1 parent c971972 commit 3a4fc4d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,3 @@ WarningsAsErrors: >-
performance*,
portability*,
readability*,
CheckOptions:
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: 'false'
2 changes: 1 addition & 1 deletion src/json-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ void ju_get_opt_field(const nlohmann::json &j, const K &key, virtio_device_confi
ju_get_opt_field(jhostfwd, "guest_ip"s, hostfwd.guest_ip, hostfwd_path);
ju_get_opt_field(jhostfwd, "host_port"s, hostfwd.host_port, hostfwd_path);
ju_get_opt_field(jhostfwd, "guest_port"s, hostfwd.guest_port, hostfwd_path);
net_user_config.hostfwd.emplace_back(std::move(hostfwd));
net_user_config.hostfwd.emplace_back(hostfwd);
}
}
value.emplace<virtio_net_user_config>(std::move(net_user_config));
Expand Down
2 changes: 1 addition & 1 deletion src/jsonrpc-virtual-machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static std::string json_post(beast::tcp_stream &stream, const std::string &remot
}

// Return response body
return std::move(res.body().data());
return res.body();
} catch (...) {
// Close stream socket on errors
beast::error_code ec;
Expand Down
12 changes: 6 additions & 6 deletions src/pma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ pma_memory::~pma_memory() {
}

pma_memory::pma_memory(pma_memory &&other) noexcept :
m_length{std::move(other.m_length)},
m_host_memory{std::move(other.m_host_memory)},
m_mmapped{std::move(other.m_mmapped)} {
m_length{other.m_length},
m_host_memory{other.m_host_memory},
m_mmapped{other.m_mmapped} {
// set other to safe state
other.m_host_memory = nullptr;
other.m_mmapped = false;
Expand Down Expand Up @@ -122,9 +122,9 @@ pma_memory::pma_memory(const std::string &description, uint64_t length, const st
pma_memory &pma_memory::operator=(pma_memory &&other) noexcept {
release();
// copy from other
m_host_memory = std::move(other.m_host_memory);
m_mmapped = std::move(other.m_mmapped);
m_length = std::move(other.m_length);
m_host_memory = other.m_host_memory;
m_mmapped = other.m_mmapped;
m_length = other.m_length;
// set other to safe state
other.m_host_memory = nullptr;
other.m_mmapped = false;
Expand Down
6 changes: 6 additions & 0 deletions src/pma.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class pma_device final {
m_context{context} {
(void) description;
}
~pma_device() = default;

pma_device(const pma_device &other) = delete;
pma_device(pma_device &&other) = default;
pma_device &operator=(const pma_device &other) = delete;
pma_device &operator=(pma_device &&other) = default;

/// \brief Returns context to pass to callbacks.
void *get_context() {
Expand Down
4 changes: 2 additions & 2 deletions src/virtio-net-carrier-slirp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static ssize_t slirp_send_packet(const void *buf, size_t len, void *opaque) {
slirp_packet packet{len};
memcpy(packet.buf.data(), buf, len);
try {
carrier->send_packets.emplace_back(std::move(packet));
carrier->send_packets.emplace_back(packet);
return static_cast<ssize_t>(len);
} catch (...) {
#ifdef DEBUG_VIRTIO_ERRORS
Expand Down Expand Up @@ -359,7 +359,7 @@ bool virtio_net_carrier_slirp::read_packet_from_host(i_device_state_access *a, v
return true;
}
// Retrieve the next packet sent by slirp.
slirp_packet packet = std::move(send_packets.front());
slirp_packet packet = send_packets.front();
send_packets.pop_front();
// Is there enough space in the write buffer to write this packet?
if (VIRTIO_NET_ETHERNET_FRAME_OFFSET + packet.len > write_avail_len) {
Expand Down

0 comments on commit 3a4fc4d

Please sign in to comment.