Drop redundant calls to Interest::setCanBePrefix(false)

Change-Id: Ib9a61700a2922a54c94c372222e3ef0d77d66de8
diff --git a/src/requester-request.cpp b/src/requester-request.cpp
index e8d6b26..7c5ab3c 100644
--- a/src/requester-request.cpp
+++ b/src/requester-request.cpp
@@ -58,11 +58,9 @@
 Request::genCaProfileInterestFromDiscoveryResponse(const Data& reply)
 {
   auto metaData = ndn::MetadataObject(reply);
-  auto interestName= metaData.getVersionedName();
+  auto interestName = metaData.getVersionedName();
   interestName.appendSegment(0);
-  auto interest = std::make_shared<Interest>(interestName);
-  interest->setCanBePrefix(false);
-  return interest;
+  return std::make_shared<Interest>(interestName);
 }
 
 optional<CaProfile>
@@ -96,7 +94,6 @@
   interestName.append("CA").append("PROBE");
   auto interest = std::make_shared<Interest>(interestName);
   interest->setMustBeFresh(true);
-  interest->setCanBePrefix(false);
   interest->setApplicationParameters(probetlv::encodeApplicationParameters(std::move(probeInfo)));
   return interest;
 }
@@ -108,7 +105,6 @@
   if (!ndn::security::verifySignature(reply, *ca.cert)) {
     NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
     NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
-    return;
   }
   processIfError(reply);
   probetlv::decodeDataContent(reply.getContent(), identityNames, otherCas);
@@ -170,11 +166,10 @@
   // generate Interest packet
   Name interestName = m_caProfile.caPrefix;
   interestName.append("CA").append("NEW");
-  auto interest =std::make_shared<Interest>(interestName);
+  auto interest = std::make_shared<Interest>(interestName);
   interest->setMustBeFresh(true);
-  interest->setCanBePrefix(false);
   interest->setApplicationParameters(
-          requesttlv::encodeApplicationParameters(RequestType::NEW, m_ecdh.getSelfPubKey(), certRequest));
+    requesttlv::encodeApplicationParameters(RequestType::NEW, m_ecdh.getSelfPubKey(), certRequest));
 
   // sign the Interest packet
   m_keyChain.sign(*interest, signingByKey(keyName));
@@ -187,14 +182,14 @@
   if (!m_caProfile.caPrefix.isPrefixOf(certificate.getName())) {
     return nullptr;
   }
+
   // generate Interest packet
   Name interestName = m_caProfile.caPrefix;
   interestName.append("CA").append("REVOKE");
-  auto interest =std::make_shared<Interest>(interestName);
+  auto interest = std::make_shared<Interest>(interestName);
   interest->setMustBeFresh(true);
-  interest->setCanBePrefix(false);
   interest->setApplicationParameters(
-          requesttlv::encodeApplicationParameters(RequestType::REVOKE, m_ecdh.getSelfPubKey(), certificate));
+    requesttlv::encodeApplicationParameters(RequestType::REVOKE, m_ecdh.getSelfPubKey(), certificate));
   return interest;
 }
 
@@ -247,9 +242,8 @@
 
   Name interestName = m_caProfile.caPrefix;
   interestName.append("CA").append("CHALLENGE").append(m_requestId.data(), m_requestId.size());
-  auto interest =std::make_shared<Interest>(interestName);
+  auto interest = std::make_shared<Interest>(interestName);
   interest->setMustBeFresh(true);
-  interest->setCanBePrefix(false);
 
   // encrypt the Interest parameters
   auto paramBlock = encodeBlockWithAesGcm128(ndn::tlv::ApplicationParameters, m_aesKey.data(),
@@ -275,13 +269,10 @@
 std::shared_ptr<Interest>
 Request::genCertFetchInterest() const
 {
-  Name interestName = m_issuedCertName;
-  auto interest = std::make_shared<Interest>(interestName);
+  auto interest = std::make_shared<Interest>(m_issuedCertName);
   if (!m_forwardingHint.empty()) {
     interest->setForwardingHint({m_forwardingHint});
   }
-  interest->setMustBeFresh(false);
-  interest->setCanBePrefix(false);
   return interest;
 }
 
@@ -292,9 +283,8 @@
     return std::make_shared<Certificate>(reply);
   }
   catch (const std::exception&) {
-    NDN_LOG_ERROR("Cannot parse replied certificate ");
-    NDN_THROW(std::runtime_error("Cannot parse replied certificate "));
-    return nullptr;
+    NDN_LOG_ERROR("Cannot parse replied certificate");
+    NDN_THROW(std::runtime_error("Cannot parse replied certificate"));
   }
 }
 
@@ -304,6 +294,7 @@
   if (m_status == Status::SUCCESS) {
     return;
   }
+
   if (m_isNewlyCreatedIdentity) {
     // put the identity into the if scope is because it may cause an error
     // outside since when endSession is called, identity may not have been created yet.
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 5dbdb3b..d2a852c 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -62,8 +62,7 @@
       // std::cout << "CA Config MetaData Size: " << response.wireEncode().size() << std::endl;
       auto block = response.getContent();
       block.parse();
-      infoInterest =std::make_shared<Interest>(Name(block.get(ndn::tlv::Name)).appendSegment(0));
-      infoInterest->setCanBePrefix(false);
+      infoInterest = std::make_shared<Interest>(Name(block.get(ndn::tlv::Name)).appendSegment(0));
       // std::cout << "CA Config fetch Interest Size: " << infoInterest->wireEncode().size() << std::endl;
     }
     else {
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 2a9640b..4e306ba 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -77,7 +77,6 @@
       auto block = response.getContent();
       block.parse();
       infoInterest = std::make_shared<Interest>(Name(block.get(ndn::tlv::Name)).appendSegment(0));
-      infoInterest->setCanBePrefix(false);
     }
     else {
       count++;
@@ -111,13 +110,10 @@
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/PROBE");
-  interest.setCanBePrefix(false);
-
   Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
   paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
   paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
   paramTLV.encode();
-
   interest.setApplicationParameters(paramTLV);
 
   int count = 0;
@@ -149,13 +145,10 @@
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/PROBE");
-  interest.setCanBePrefix(false);
-
   Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
   paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
   paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
   paramTLV.encode();
-
   interest.setApplicationParameters(paramTLV);
 
   int count = 0;
@@ -187,13 +180,10 @@
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/PROBE");
-  interest.setCanBePrefix(false);
-
   Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
   paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
   paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
   paramTLV.encode();
-
   interest.setApplicationParameters(paramTLV);
 
   int count = 0;