build: stop defining _DEBUG, rely only on NDEBUG instead
NDEBUG is more standard on non-Microsoft platforms, and _DEBUG is
technically a reserved identifier.
Change-Id: I24c951032d50b37853dc1a38ac844b0be5ac8937
diff --git a/daemon/face/datagram-transport.hpp b/daemon/face/datagram-transport.hpp
index e34e443..923dde3 100644
--- a/daemon/face/datagram-transport.hpp
+++ b/daemon/face/datagram-transport.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -99,14 +99,13 @@
private:
std::array<uint8_t, ndn::MAX_NDN_PACKET_SIZE> m_receiveBuffer;
- bool m_hasRecentlyReceived;
+ bool m_hasRecentlyReceived = false;
};
template<class T, class U>
DatagramTransport<T, U>::DatagramTransport(typename DatagramTransport::protocol::socket&& socket)
: m_socket(std::move(socket))
- , m_hasRecentlyReceived(false)
{
boost::asio::socket_base::send_buffer_size sendBufferSizeOption;
boost::system::error_code error;
diff --git a/daemon/face/ethernet-channel.cpp b/daemon/face/ethernet-channel.cpp
index 655f313..dfd5bf3 100644
--- a/daemon/face/ethernet-channel.cpp
+++ b/daemon/face/ethernet-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -40,13 +40,9 @@
EthernetChannel::EthernetChannel(shared_ptr<const ndn::net::NetworkInterface> localEndpoint,
time::nanoseconds idleTimeout)
: m_localEndpoint(std::move(localEndpoint))
- , m_isListening(false)
, m_socket(getGlobalIoService())
, m_pcap(m_localEndpoint->getName())
, m_idleFaceTimeout(idleTimeout)
-#ifdef _DEBUG
- , m_nDropped(0)
-#endif
{
setUri(FaceUri::fromDev(m_localEndpoint->getName()));
NFD_LOG_CHAN_INFO("Creating channel");
@@ -137,7 +133,7 @@
}
}
-#ifdef _DEBUG
+#ifndef NDEBUG
size_t nDropped = m_pcap.getNDropped();
if (nDropped - m_nDropped > 0)
NFD_LOG_CHAN_DEBUG("Detected " << nDropped - m_nDropped << " dropped frame(s)");
diff --git a/daemon/face/ethernet-channel.hpp b/daemon/face/ethernet-channel.hpp
index 302b6e7..c675a52 100644
--- a/daemon/face/ethernet-channel.hpp
+++ b/daemon/face/ethernet-channel.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -121,15 +121,15 @@
private:
shared_ptr<const ndn::net::NetworkInterface> m_localEndpoint;
- bool m_isListening;
+ bool m_isListening = false;
boost::asio::posix::stream_descriptor m_socket;
PcapHelper m_pcap;
std::map<ethernet::Address, shared_ptr<Face>> m_channelFaces;
const time::nanoseconds m_idleFaceTimeout; ///< Timeout for automatic closure of idle on-demand faces
-#ifdef _DEBUG
- /// number of frames dropped by the kernel, as reported by libpcap
- size_t m_nDropped;
+#ifndef NDEBUG
+ /// Number of frames dropped by the kernel, as reported by libpcap
+ size_t m_nDropped = 0;
#endif
};
diff --git a/daemon/face/ethernet-protocol.cpp b/daemon/face/ethernet-protocol.cpp
index 24478f8..137ff27 100644
--- a/daemon/face/ethernet-protocol.cpp
+++ b/daemon/face/ethernet-protocol.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -43,7 +43,7 @@
if (ethertype != ETHERTYPE_NDN)
return {nullptr, "Received frame with wrong ethertype: " + to_string(ethertype)};
-#ifdef _DEBUG
+#ifndef NDEBUG
Address shost(eh->ether_shost);
if (shost == localAddr)
return {nullptr, "Received frame sent by this host"};
diff --git a/daemon/face/ethernet-transport.cpp b/daemon/face/ethernet-transport.cpp
index bc496d6..43f7e91 100644
--- a/daemon/face/ethernet-transport.cpp
+++ b/daemon/face/ethernet-transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -43,10 +43,6 @@
, m_srcAddress(localEndpoint.getEthernetAddress())
, m_destAddress(remoteEndpoint)
, m_interfaceName(localEndpoint.getName())
- , m_hasRecentlyReceived(false)
-#ifdef _DEBUG
- , m_nDropped(0)
-#endif
{
try {
m_pcap.activate(DLT_EN10MB);
@@ -183,7 +179,7 @@
}
}
-#ifdef _DEBUG
+#ifndef NDEBUG
size_t nDropped = m_pcap.getNDropped();
if (nDropped - m_nDropped > 0)
NFD_LOG_FACE_DEBUG("Detected " << nDropped - m_nDropped << " dropped frame(s)");
diff --git a/daemon/face/ethernet-transport.hpp b/daemon/face/ethernet-transport.hpp
index a1d3c80..065919e 100644
--- a/daemon/face/ethernet-transport.hpp
+++ b/daemon/face/ethernet-transport.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -106,10 +106,10 @@
private:
signal::ScopedConnection m_netifStateChangedConn;
signal::ScopedConnection m_netifMtuChangedConn;
- bool m_hasRecentlyReceived;
-#ifdef _DEBUG
- /// number of frames dropped by the kernel, as reported by libpcap
- size_t m_nDropped;
+ bool m_hasRecentlyReceived = false;
+#ifndef NDEBUG
+ /// Number of frames dropped by the kernel, as reported by libpcap
+ size_t m_nDropped = 0;
#endif
};
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index 21599e3..de073b4 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -44,9 +44,6 @@
, m_fragmenter(m_options.fragmenterOptions, this)
, m_reassembler(m_options.reassemblerOptions, this)
, m_reliability(m_options.reliabilityOptions, this)
- , m_lastSeqNo(-2)
- , m_nextMarkTime(time::steady_clock::time_point::max())
- , m_nMarkedSinceInMarkingState(0)
{
m_reassembler.beforeTimeout.connect([this] (auto&&...) { ++nReassemblyTimeouts; });
m_reliability.onDroppedInterest.connect([this] (const auto& i) { notifyDroppedInterest(i); });
diff --git a/daemon/face/generic-link-service.hpp b/daemon/face/generic-link-service.hpp
index 7b5a427..547ca67 100644
--- a/daemon/face/generic-link-service.hpp
+++ b/daemon/face/generic-link-service.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -308,13 +308,13 @@
LpFragmenter m_fragmenter;
LpReassembler m_reassembler;
LpReliability m_reliability;
- lp::Sequence m_lastSeqNo;
+ lp::Sequence m_lastSeqNo = static_cast<lp::Sequence>(-2);
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/// Time to mark next packet due to send queue congestion
- time::steady_clock::time_point m_nextMarkTime;
- /// number of marked packets in the current incident of congestion
- size_t m_nMarkedSinceInMarkingState;
+ time::steady_clock::time_point m_nextMarkTime = time::steady_clock::time_point::max();
+ /// Number of marked packets in the current incident of congestion
+ size_t m_nMarkedSinceInMarkingState = 0;
friend LpReliability;
};
diff --git a/daemon/face/lp-reliability.cpp b/daemon/face/lp-reliability.cpp
index 4019902..107212e 100644
--- a/daemon/face/lp-reliability.cpp
+++ b/daemon/face/lp-reliability.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -400,21 +400,6 @@
}
}
-LpReliability::UnackedFrag::UnackedFrag(lp::Packet pkt)
- : pkt(std::move(pkt))
- , sendTime(time::steady_clock::now())
- , retxCount(0)
- , nGreaterSeqAcks(0)
-{
-}
-
-LpReliability::NetPkt::NetPkt(lp::Packet&& pkt, bool isInterest)
- : pkt(std::move(pkt))
- , isInterest(isInterest)
- , didRetx(false)
-{
-}
-
std::ostream&
operator<<(std::ostream& os, const FaceLogHelper<LpReliability>& flh)
{
diff --git a/daemon/face/lp-reliability.hpp b/daemon/face/lp-reliability.hpp
index 415a06d..3a4d703 100644
--- a/daemon/face/lp-reliability.hpp
+++ b/daemon/face/lp-reliability.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -174,14 +174,17 @@
{
public:
explicit
- UnackedFrag(lp::Packet pkt);
+ UnackedFrag(lp::Packet p)
+ : pkt(std::move(p))
+ {
+ }
public:
lp::Packet pkt;
scheduler::ScopedEventId rtoTimer;
- time::steady_clock::time_point sendTime;
- size_t retxCount;
- size_t nGreaterSeqAcks; //!< number of Acks received for sequences greater than this fragment
+ time::steady_clock::time_point sendTime = time::steady_clock::now();
+ size_t retxCount = 0;
+ size_t nGreaterSeqAcks = 0; ///< Number of Acks received for sequences greater than this fragment
shared_ptr<NetPkt> netPkt;
};
@@ -191,17 +194,21 @@
class NetPkt
{
public:
- NetPkt(lp::Packet&& pkt, bool isInterest);
+ NetPkt(lp::Packet&& p, bool isInterest)
+ : pkt(std::move(p))
+ , isInterest(isInterest)
+ {
+ }
public:
std::vector<UnackedFrags::iterator> unackedFrags;
lp::Packet pkt;
bool isInterest;
- bool didRetx;
+ bool didRetx = false;
};
Options m_options;
- GenericLinkService* m_linkService;
+ GenericLinkService* m_linkService = nullptr;
UnackedFrags m_unackedFrags;
// An iterator that points to the first unacknowledged fragment in the current window. The window
// can wrap around so that the beginning of the window is at a TxSequence greater than other
diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp
index 448b28b..bd6cc12 100644
--- a/daemon/face/stream-transport.hpp
+++ b/daemon/face/stream-transport.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -105,17 +105,15 @@
private:
uint8_t m_receiveBuffer[ndn::MAX_NDN_PACKET_SIZE];
- size_t m_receiveBufferSize;
+ size_t m_receiveBufferSize = 0;
std::queue<Block> m_sendQueue;
- size_t m_sendQueueBytes;
+ size_t m_sendQueueBytes = 0;
};
template<class T>
StreamTransport<T>::StreamTransport(typename StreamTransport::protocol::socket&& socket)
: m_socket(std::move(socket))
- , m_receiveBufferSize(0)
- , m_sendQueueBytes(0)
{
// No queue capacity is set because there is no theoretical limit to the size of m_sendQueue.
// Therefore, protecting against send queue overflows is less critical than in other transport