Resolve ASan errors that will be thrown once it is turned on
Plus few minor spelling and code-style issues
refs: #4230
Change-Id: Ia665bab546a9628347af45836dcbe765dc91c54f
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 9173b89..99cd285 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -196,7 +196,7 @@
const ndn::time::seconds& expTime)
{
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
- std::bind(&Lsdb::exprireOrRefreshNameLsa, this, key, seqNo));
+ std::bind(&Lsdb::expireOrRefreshNameLsa, this, key, seqNo));
}
bool
@@ -438,7 +438,7 @@
const ndn::time::seconds& expTime)
{
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
- std::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
+ std::bind(&Lsdb::expireOrRefreshCoordinateLsa,
this, key, seqNo));
}
@@ -696,7 +696,7 @@
const ndn::time::seconds& expTime)
{
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
- std::bind(&Lsdb::exprireOrRefreshAdjLsa, this, key, seqNo));
+ std::bind(&Lsdb::expireOrRefreshAdjLsa, this, key, seqNo));
}
bool
@@ -826,9 +826,9 @@
// lsaKey is the key of the LSA's publishing router.
// seqNo is the seq. no. of the candidate LSA.
void
-Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
+Lsdb::expireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
{
- _LOG_DEBUG("Lsdb::exprireOrRefreshNameLsa Called");
+ _LOG_DEBUG("Lsdb::expireOrRefreshNameLsa Called");
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
NameLsa* chkNameLsa = findNameLsa(lsaKey);
// If this name LSA exists in the LSDB
@@ -869,9 +869,9 @@
// lsaKey is the key of the LSA's publishing router.
// seqNo is the seq. no. of the candidate LSA.
void
-Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
+Lsdb::expireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
{
- _LOG_DEBUG("Lsdb::exprireOrRefreshAdjLsa Called");
+ _LOG_DEBUG("Lsdb::expireOrRefreshAdjLsa Called");
_LOG_DEBUG("LSA Key: " << lsaKey << " Seq No: " << seqNo);
AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
// If this is a valid LSA
@@ -916,10 +916,10 @@
// lsaKey is the key of the LSA's publishing router.
// seqNo is the seq. no. of the candidate LSA.
void
-Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
+Lsdb::expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
uint64_t seqNo)
{
- _LOG_DEBUG("Lsdb::exprireOrRefreshCorLsa Called ");
+ _LOG_DEBUG("Lsdb::expireOrRefreshCorLsa Called ");
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
// Whether the LSA is in the LSDB or not.
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 1ac25f2..2b182bd 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -22,18 +22,18 @@
#ifndef NLSR_LSDB_HPP
#define NLSR_LSDB_HPP
-#include <utility>
-#include <boost/cstdint.hpp>
-
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/util/time.hpp>
-
#include "conf-parameter.hpp"
#include "lsa.hpp"
#include "sequencing-manager.hpp"
#include "test-access-control.hpp"
#include "communication/sync-logic-handler.hpp"
+#include <utility>
+#include <boost/cstdint.hpp>
+
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/util/time.hpp>
+
namespace nlsr {
using namespace ndn::time;
@@ -271,7 +271,7 @@
\param seqNo The seq. no. of the LSA to check.
*/
void
- exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
+ expireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/*! \brief Schedules an expire/refresh event in the LSA.
@@ -286,14 +286,14 @@
private:
void
- exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
+ expireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
ndn::EventId
scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
const seconds& expTime);
void
- exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
+ expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
uint64_t seqNo);
private:
diff --git a/src/publisher/lsdb-dataset-interest-handler.cpp b/src/publisher/lsdb-dataset-interest-handler.cpp
index e3cfa1f..acd5c92 100644
--- a/src/publisher/lsdb-dataset-interest-handler.cpp
+++ b/src/publisher/lsdb-dataset-interest-handler.cpp
@@ -27,24 +27,22 @@
*/
#include "lsdb-dataset-interest-handler.hpp"
-
#include "logger.hpp"
#include "nlsr.hpp"
+#include "tlv/lsdb-status.hpp"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
#include <ndn-cxx/util/regex.hpp>
-#include "tlv/lsdb-status.hpp"
namespace nlsr {
INIT_LOGGER("LsdbDatasetInterestHandler");
+
const ndn::PartialName ADJACENCIES_DATASET = ndn::PartialName("lsdb/adjacencies");
const ndn::PartialName COORDINATES_DATASET = ndn::PartialName("lsdb/coordinates");
const ndn::PartialName NAMES_DATASET = ndn::PartialName("lsdb/names");
const ndn::PartialName LISTS_DATASET = ndn::PartialName("lsdb/list");
-const ndn::PartialName LsdbDatasetInterestHandler::LOCALHOST_COMMAND_PREFIX =
- ndn::Name(Nlsr::LOCALHOST_PREFIX).append(Lsdb::NAME_COMPONENT);
LsdbDatasetInterestHandler::LsdbDatasetInterestHandler(Lsdb& lsdb,
ndn::mgmt::Dispatcher& localHostDispatcher,
diff --git a/src/publisher/lsdb-dataset-interest-handler.hpp b/src/publisher/lsdb-dataset-interest-handler.hpp
index f16075f..f8aa025 100644
--- a/src/publisher/lsdb-dataset-interest-handler.hpp
+++ b/src/publisher/lsdb-dataset-interest-handler.hpp
@@ -23,13 +23,13 @@
#define NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
#include "lsa-publisher.hpp"
+#include "tlv/adjacency-lsa.hpp"
+#include "tlv/coordinate-lsa.hpp"
+#include "tlv/name-lsa.hpp"
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/face.hpp>
#include <boost/noncopyable.hpp>
-#include "tlv/adjacency-lsa.hpp"
-#include "tlv/coordinate-lsa.hpp"
-#include "tlv/name-lsa.hpp"
namespace nlsr {
@@ -56,12 +56,6 @@
ndn::Face& face,
ndn::KeyChain& keyChain);
- const ndn::Name&
- getLocalhostCommandPrefix()
- {
- return LOCALHOST_COMMAND_PREFIX;
- }
-
ndn::Name&
getRouterNameCommandPrefix()
{
@@ -105,7 +99,6 @@
ndn::mgmt::StatusDatasetContext& context);
private:
- static const ndn::Name LOCALHOST_COMMAND_PREFIX;
ndn::Name m_routerNamePrefix;
ndn::mgmt::Dispatcher& m_localhostDispatcher;
diff --git a/src/route/name-prefix-table-entry.cpp b/src/route/name-prefix-table-entry.cpp
index 1abc87b..d9f8c65 100644
--- a/src/route/name-prefix-table-entry.cpp
+++ b/src/route/name-prefix-table-entry.cpp
@@ -33,9 +33,9 @@
NamePrefixTableEntry::generateNhlfromRteList()
{
m_nexthopList.reset();
- for (auto rtpeItr = m_rteList.begin(); rtpeItr != m_rteList.end(); ++rtpeItr) {
- for (auto nhItr = (*rtpeItr)->getNexthopList().getNextHops().begin();
- nhItr != (*rtpeItr)->getNexthopList().getNextHops().end();
+ for (auto iterator = m_rteList.begin(); iterator != m_rteList.end(); ++iterator) {
+ for (auto nhItr = (*iterator)->getNexthopList().getNextHops().begin();
+ nhItr != (*iterator)->getNexthopList().getNextHops().end();
++nhItr) {
m_nexthopList.addNextHop((*nhItr));
}
@@ -44,32 +44,32 @@
uint64_t
NamePrefixTableEntry::removeRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry>
- rtpePtr)
+ entryPtr)
{
- auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
+ auto iterator = std::find(m_rteList.begin(), m_rteList.end(), entryPtr);
- if (rtpeItr != m_rteList.end()) {
- (*rtpeItr)->decrementUseCount();
- m_rteList.erase(rtpeItr);
+ if (iterator != m_rteList.end()) {
+ (*iterator)->decrementUseCount();
+ m_rteList.erase(iterator);
}
else {
- _LOG_ERROR("Routing entry for: " << rtpePtr->getDestination()
+ _LOG_ERROR("Routing entry for: " << entryPtr->getDestination()
<< " not found in NPT entry: " << getNamePrefix());
}
- return (*rtpeItr)->getUseCount();
+ return entryPtr->getUseCount();
}
void
NamePrefixTableEntry::addRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry>
- rtpePtr)
+ entryPtr)
{
- auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
+ auto iterator = std::find(m_rteList.begin(), m_rteList.end(), entryPtr);
// Ensure that this is a new entry
- if (rtpeItr == m_rteList.end()) {
+ if (iterator == m_rteList.end()) {
// Adding a new routing entry to the NPT entry
- rtpePtr->incrementUseCount();
- m_rteList.push_back(rtpePtr);
+ entryPtr->incrementUseCount();
+ m_rteList.push_back(entryPtr);
}
// Note: we don't need to update in the else case because these are
// pointers, and they are centrally-located in the NPT and will all
@@ -105,8 +105,8 @@
{
os << "Name: " << entry.getNamePrefix() << "\n";
- for (const std::shared_ptr<RoutingTablePoolEntry> rtpePtr : entry.getRteList()) {
- os << "Destination: " << rtpePtr->getDestination() << "\n";
+ for (const std::shared_ptr<RoutingTablePoolEntry> entryPtr : entry.getRteList()) {
+ os << "Destination: " << entryPtr->getDestination() << "\n";
}
return os;
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index 6467790..251bfc5 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -45,8 +45,8 @@
// Check if the advertised name prefix is in the table already.
NptEntryList::iterator nameItr = std::find(m_table.begin(),
- m_table.end(),
- name);
+ m_table.end(),
+ name);
// Attempt to find a routing table pool entry (RTPE) we can use.
RtpEntryMap::iterator rtpeItr = m_rtpool.find(destRouter);
@@ -139,9 +139,8 @@
std::shared_ptr<RoutingTablePoolEntry> rtpePtr = rtpeItr->second;
// Ensure that the entry exists
- NptEntryList::iterator nameItr = std::find_if(m_table.begin(),
- m_table.end(),
- std::bind(&npteCompare, _1, name));
+ NptEntryList::iterator nameItr = std::find_if(m_table.begin(), m_table.end(),
+ std::bind(&npteCompare, _1, name));
if (nameItr != m_table.end()) {
_LOG_TRACE("Removing origin: " << rtpePtr->getDestination()
<< " from prefix: " << *nameItr);
@@ -182,7 +181,7 @@
}
else {
_LOG_DEBUG("Attempted to remove origin: " << rtpePtr->getDestination()
- << " from non-existant prefix: " << name);
+ << " from non-existent prefix: " << name);
}
}
@@ -239,7 +238,7 @@
NamePrefixTable::deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr)
{
if (m_rtpool.erase(rtpePtr->getDestination()) != 1) {
- _LOG_DEBUG("Attempted to delete non-existant origin: "
+ _LOG_DEBUG("Attempted to delete non-existent origin: "
<< rtpePtr->getDestination()
<< " from NPT routing table entry storage pool.");
}