aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport
diff options
context:
space:
mode:
authorMichele Papalini <micpapal@cisco.com>2023-02-02 17:49:46 +0100
committerMichele Papalini <micpapal@cisco.com>2023-02-07 10:25:01 +0100
commit8a7e75e84a31180d51b9970d526709ec4dca2030 (patch)
tree48c1d88f0a5635e75fa9fc0eb898b861b42477e8 /libtransport
parentb96d1545a8d2a173dc5911ed0bca3e04dbb02176 (diff)
fix(hicn): fix bugs reported by sonarqube
Ref: HICN-837 Signed-off-by: Michele Papalini <micpapal@cisco.com> Change-Id: I0d02a11361b1ba5ad50123b2dd142c961998922f
Diffstat (limited to 'libtransport')
-rw-r--r--libtransport/includes/hicn/transport/core/connector.h2
-rw-r--r--libtransport/src/core/memif_connector.cc8
-rw-r--r--libtransport/src/core/pending_interest.h8
-rw-r--r--libtransport/src/protocols/incremental_indexer_bytestream.h2
-rw-r--r--libtransport/src/protocols/rtc/rtc_indexer.h2
-rw-r--r--libtransport/src/utils/fd_deadline_timer.h3
6 files changed, 18 insertions, 7 deletions
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<Connector> {
}
template <typename OnReconnect>
- void setReconnectCallback(const OnReconnect &&callback) {
+ void setReconnectCallback(OnReconnect &&callback) {
on_reconnect_callback_ = std::forward<OnReconnect>(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<Handler>(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<Indexer>(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<Indexer>(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<FdDeadlineTimer> {
template <typename T, typename R>
void expiresFromNowImpl(std::chrono::duration<T, R> &&duration) {
std::memset(&new_value_, 0, sizeof(new_value_));
- new_value_.it_value = std::chrono::duration_cast<struct timespec>(
- std::forward<std::chrono::duration<T, R>>(duration));
+ new_value_.it_value = std::chrono::duration_cast<struct timespec>(duration);
}
template <typename TimePoint,