From 8a7e75e84a31180d51b9970d526709ec4dca2030 Mon Sep 17 00:00:00 2001 From: Michele Papalini Date: Thu, 2 Feb 2023 17:49:46 +0100 Subject: fix(hicn): fix bugs reported by sonarqube Ref: HICN-837 Signed-off-by: Michele Papalini Change-Id: I0d02a11361b1ba5ad50123b2dd142c961998922f --- libtransport/includes/hicn/transport/core/connector.h | 2 +- libtransport/src/core/memif_connector.cc | 8 +++++++- libtransport/src/core/pending_interest.h | 8 +++++++- libtransport/src/protocols/incremental_indexer_bytestream.h | 2 +- libtransport/src/protocols/rtc/rtc_indexer.h | 2 +- libtransport/src/utils/fd_deadline_timer.h | 3 +-- 6 files changed, 18 insertions(+), 7 deletions(-) (limited to 'libtransport') diff --git a/libtransport/includes/hicn/transport/core/connector.h b/libtransport/includes/hicn/transport/core/connector.h index be191fb4a..7882b285d 100644 --- a/libtransport/includes/hicn/transport/core/connector.h +++ b/libtransport/includes/hicn/transport/core/connector.h @@ -96,7 +96,7 @@ class Connector : public std::enable_shared_from_this { } template - void setReconnectCallback(const OnReconnect &&callback) { + void setReconnectCallback(OnReconnect &&callback) { on_reconnect_callback_ = std::forward(callback); } diff --git a/libtransport/src/core/memif_connector.cc b/libtransport/src/core/memif_connector.cc index fb38a6e23..a224beb11 100644 --- a/libtransport/src/core/memif_connector.cc +++ b/libtransport/src/core/memif_connector.cc @@ -55,7 +55,13 @@ MemifConnector::MemifConnector(PacketReceivedCallback &&receive_callback, log2_ring_size_(klog2_ring_size), max_memif_bufs_(1 << klog2_ring_size) {} -MemifConnector::~MemifConnector() { close(); } +MemifConnector::~MemifConnector() { + try { + close(); + } catch (errors::RuntimeException &e) { + // do nothing + } +} void MemifConnector::connect(uint32_t memif_id, long memif_mode, const std::string &socket_filename, diff --git a/libtransport/src/core/pending_interest.h b/libtransport/src/core/pending_interest.h index b901e7d97..f49348bac 100644 --- a/libtransport/src/core/pending_interest.h +++ b/libtransport/src/core/pending_interest.h @@ -62,7 +62,13 @@ class PendingInterest { timer_.async_wait(std::forward(cb)); } - void cancelTimer() { timer_.cancel(); } + void cancelTimer() { + try { + timer_.cancel(); + } catch (asio::system_error &e) { + // do nothing + } + } Interest::Ptr &&getInterest() { return std::move(interest_); } diff --git a/libtransport/src/protocols/incremental_indexer_bytestream.h b/libtransport/src/protocols/incremental_indexer_bytestream.h index 422e49ecd..4f9b6126f 100644 --- a/libtransport/src/protocols/incremental_indexer_bytestream.h +++ b/libtransport/src/protocols/incremental_indexer_bytestream.h @@ -48,7 +48,7 @@ class IncrementalIndexer : public Indexer { IncrementalIndexer(const IncrementalIndexer &other) = delete; IncrementalIndexer(IncrementalIndexer &&other) - : Indexer(std::forward(other)), + : Indexer(other), final_suffix_(other.final_suffix_), first_suffix_(other.first_suffix_), next_download_suffix_(other.next_download_suffix_), diff --git a/libtransport/src/protocols/rtc/rtc_indexer.h b/libtransport/src/protocols/rtc/rtc_indexer.h index cda156b22..f87fcaaa2 100644 --- a/libtransport/src/protocols/rtc/rtc_indexer.h +++ b/libtransport/src/protocols/rtc/rtc_indexer.h @@ -47,7 +47,7 @@ class RtcIndexer : public Indexer { n_fec_(0), n_current_fec_(n_fec_) {} - RtcIndexer(RtcIndexer &&other) : Indexer(std::forward(other)) {} + RtcIndexer(RtcIndexer &&other) : Indexer(other) {} ~RtcIndexer() {} diff --git a/libtransport/src/utils/fd_deadline_timer.h b/libtransport/src/utils/fd_deadline_timer.h index cf0cde112..7ecbba69b 100644 --- a/libtransport/src/utils/fd_deadline_timer.h +++ b/libtransport/src/utils/fd_deadline_timer.h @@ -92,8 +92,7 @@ class FdDeadlineTimer : public DeadlineTimer { template void expiresFromNowImpl(std::chrono::duration &&duration) { std::memset(&new_value_, 0, sizeof(new_value_)); - new_value_.it_value = std::chrono::duration_cast( - std::forward>(duration)); + new_value_.it_value = std::chrono::duration_cast(duration); } template