Fix a couple of dangling-reference and maybe-uninitialized warnings
Change-Id: Iac5df0dbe8400c93ff825c1cecd96933292a3b81
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index be197d6..842ab39 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2023, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -121,10 +121,8 @@
CaModule::getCaProfileData()
{
if (m_profileData == nullptr) {
- const auto& pib = m_keyChain.getPib();
- const auto& identity = pib.getIdentity(m_config.caProfile.caPrefix);
- const auto& cert = identity.getDefaultKey().getDefaultCertificate();
- Block contentTLV = infotlv::encodeDataContent(m_config.caProfile, cert);
+ auto key = m_keyChain.getPib().getIdentity(m_config.caProfile.caPrefix).getDefaultKey();
+ Block contentTLV = infotlv::encodeDataContent(m_config.caProfile, key.getDefaultCertificate());
Name infoPacketName(m_config.caProfile.caPrefix);
auto segmentComp = ndn::name::Component::fromSegment(0);
@@ -153,7 +151,8 @@
}
void
-CaModule::onProbe(const Interest& request) {
+CaModule::onProbe(const Interest& request)
+{
// PROBE Naming Convention: /<CA-Prefix>/CA/PROBE/[ParametersSha256DigestComponent]
NDN_LOG_TRACE("Received PROBE request");
@@ -163,19 +162,20 @@
try {
auto parameters = probetlv::decodeApplicationParameters(request.getApplicationParameters());
- //collect redirections
+ // collect redirections
for (auto &item : m_config.redirection) {
if (item.second->isRedirecting(parameters)) {
redirectionNames.push_back(item.first->getFullName());
}
}
- //collect name assignments
+ // collect name assignments
for (auto &item : m_config.nameAssignmentFuncs) {
auto names = item->assignName(parameters);
availableComponents.insert(availableComponents.end(), names.begin(), names.end());
}
- } catch (const std::exception& e) {
+ }
+ catch (const std::exception& e) {
NDN_LOG_ERROR("[CaModule::onProbe]Error in decoding TLV: " << e.what());
return;
}
@@ -195,8 +195,8 @@
Data result;
result.setName(request.getName());
- result.setContent(
- probetlv::encodeDataContent(availableNames, m_config.caProfile.maxSuffixLength, redirectionNames));
+ result.setContent(probetlv::encodeDataContent(availableNames, m_config.caProfile.maxSuffixLength,
+ redirectionNames));
result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
m_keyChain.sign(result, signingByIdentity(m_config.caProfile.caPrefix));
m_face.put(result);
@@ -206,11 +206,11 @@
void
CaModule::onNewRenewRevoke(const Interest& request, RequestType requestType)
{
- //verify ca cert validity
- const auto& caCert = m_keyChain.getPib()
- .getIdentity(m_config.caProfile.caPrefix)
- .getDefaultKey()
- .getDefaultCertificate();
+ // verify ca cert validity
+ auto caCert = m_keyChain.getPib()
+ .getIdentity(m_config.caProfile.caPrefix)
+ .getDefaultKey()
+ .getDefaultCertificate();
if (!caCert.isValid()) {
NDN_LOG_ERROR("Server certificate invalid/expired");
m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_VALIDITY_PERIOD,