Browse Source

[1198] some trivial cleanups:
- constify things as much as possible
- a bit of style fixes (brace position, etc)

JINMEI Tatuya 13 years ago
parent
commit
0337c552ff
2 changed files with 34 additions and 33 deletions
  1. 24 24
      src/lib/datasrc/database.cc
  2. 10 9
      src/lib/datasrc/database.h

+ 24 - 24
src/lib/datasrc/database.cc

@@ -392,17 +392,18 @@ DatabaseClient::Finder::findNSECCover(const Name& name) {
 
 
 DatabaseClient::Finder::DelegationSearchResult
 DatabaseClient::Finder::DelegationSearchResult
 DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
 DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
-                                            const FindOptions options) {
+                                            const FindOptions options)
+{
     // Result of search
     // Result of search
-    isc::dns::RRsetPtr result_rrset;
+    isc::dns::ConstRRsetPtr result_rrset;
     ZoneFinder::Result result_status = SUCCESS;
     ZoneFinder::Result result_status = SUCCESS;
 
 
     // In case we are in GLUE_OK mode and start matching wildcards,
     // In case we are in GLUE_OK mode and start matching wildcards,
     // we can't do it under NS, so we store it here to check
     // we can't do it under NS, so we store it here to check
-    isc::dns::RRsetPtr first_ns;
+    isc::dns::ConstRRsetPtr first_ns;
 
 
     // Are we searching for glue?
     // Are we searching for glue?
-    bool glue_ok((options & FIND_GLUE_OK) != 0);
+    const bool glue_ok((options & FIND_GLUE_OK) != 0);
 
 
     // First, do we have any kind of delegation (NS/DNAME) here?
     // First, do we have any kind of delegation (NS/DNAME) here?
     const Name origin(getOrigin());
     const Name origin(getOrigin());
@@ -418,14 +419,14 @@ DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
     // Go through all superdomains from the origin down searching for nodes
     // Go through all superdomains from the origin down searching for nodes
     // that indicate a delegation (NS or DNAME).
     // that indicate a delegation (NS or DNAME).
     for (int i = remove_labels; i > 0; --i) {
     for (int i = remove_labels; i > 0; --i) {
-        Name superdomain(name.split(i));
+        const Name superdomain(name.split(i));
 
 
         // Note if this is the origin.
         // Note if this is the origin.
-        bool not_origin = (i != remove_labels);
+        const bool not_origin = (i != remove_labels);
 
 
         // Look if there's NS or DNAME (but ignore the NS in origin)
         // Look if there's NS or DNAME (but ignore the NS in origin)
-        FoundRRsets found = getRRsets(superdomain.toText(), DELEGATION_TYPES(),
-                                      not_origin);
+        const FoundRRsets found = getRRsets(superdomain.toText(),
+                                            DELEGATION_TYPES(), not_origin);
         if (found.first) {
         if (found.first) {
             // It contains some RRs, so it exists.
             // It contains some RRs, so it exists.
             last_known = superdomain.getLabelCount();
             last_known = superdomain.getLabelCount();
@@ -470,13 +471,13 @@ DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
 }
 }
 
 
 DatabaseClient::Finder::WildcardSearchResult
 DatabaseClient::Finder::WildcardSearchResult
-DatabaseClient::Finder::findWildcardMatch(const isc::dns::Name& name,
-                                          const isc::dns::RRType& type,
-                                          const FindOptions options,
-                                          isc::dns::RRsetPtr& first_ns,
-                                          size_t last_known) {
+DatabaseClient::Finder::findWildcardMatch(
+    const isc::dns::Name& name, const isc::dns::RRType& type,
+    const FindOptions options, const isc::dns::ConstRRsetPtr& first_ns,
+    size_t last_known)
+{
     // Result of search
     // Result of search
-    isc::dns::RRsetPtr result_rrset;
+    isc::dns::ConstRRsetPtr result_rrset;
     ZoneFinder::Result result_status = SUCCESS;
     ZoneFinder::Result result_status = SUCCESS;
 
 
     // Search options
     // Search options
@@ -593,24 +594,24 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
     LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_FIND_RECORDS)
     LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_FIND_RECORDS)
               .arg(accessor_->getDBName()).arg(name).arg(type);
               .arg(accessor_->getDBName()).arg(name).arg(type);
 
 
-    bool glue_ok((options & FIND_GLUE_OK) != 0);
+    const bool glue_ok((options & FIND_GLUE_OK) != 0);
     const bool dnssec_data((options & FIND_DNSSEC) != 0);
     const bool dnssec_data((options & FIND_DNSSEC) != 0);
 
 
     bool records_found = false; // Distinguish between NXDOMAIN and NXRRSET
     bool records_found = false; // Distinguish between NXDOMAIN and NXRRSET
     bool get_cover = false;
     bool get_cover = false;
-    isc::dns::RRsetPtr result_rrset;
+    isc::dns::ConstRRsetPtr result_rrset;
     ZoneFinder::Result result_status = SUCCESS;
     ZoneFinder::Result result_status = SUCCESS;
     const Name origin(getOrigin());
     const Name origin(getOrigin());
 
 
     // First stage: go throught all superdomains from the origin down,
     // First stage: go throught all superdomains from the origin down,
     // searching for nodes that indicate a delegation (NS or DNAME).
     // searching for nodes that indicate a delegation (NS or DNAME).
-    DelegationSearchResult dresult = findDelegationPoint(name, options);
+    const DelegationSearchResult dresult = findDelegationPoint(name, options);
     result_status = dresult.code;
     result_status = dresult.code;
     result_rrset = dresult.rrset;
     result_rrset = dresult.rrset;
 
 
     // In case we are in GLUE_OK mode and start matching wildcards,
     // In case we are in GLUE_OK mode and start matching wildcards,
     // we can't do it under NS, so we store it here to check
     // we can't do it under NS, so we store it here to check
-    isc::dns::RRsetPtr first_ns = dresult.first_ns;
+    const isc::dns::ConstRRsetPtr first_ns = dresult.first_ns;
     size_t last_known = dresult.last_known;
     size_t last_known = dresult.last_known;
 
 
     if (!result_rrset) { // Only if we didn't find a redirect already
     if (!result_rrset) { // Only if we didn't find a redirect already
@@ -620,8 +621,8 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
         // And we don't consider the NS in origin
         // And we don't consider the NS in origin
         WantedTypes final_types(FINAL_TYPES());
         WantedTypes final_types(FINAL_TYPES());
         final_types.insert(type);
         final_types.insert(type);
-        FoundRRsets found = getRRsets(name.toText(), final_types,
-                                      name != origin);
+        const FoundRRsets found = getRRsets(name.toText(), final_types,
+                                            name != origin);
         records_found = found.first;
         records_found = found.first;
 
 
         // NS records, CNAME record and Wanted Type records
         // NS records, CNAME record and Wanted Type records
@@ -675,10 +676,9 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
                 // It's not an empty non-terminal so check for wildcards.
                 // It's not an empty non-terminal so check for wildcards.
                 // We remove labels one by one and look for the wildcard there.
                 // We remove labels one by one and look for the wildcard there.
                 // Go up to first non-empty domain.
                 // Go up to first non-empty domain.
-                WildcardSearchResult wresult = findWildcardMatch(name, type,
-                                                                 options,
-                                                                 first_ns,
-                                                                 last_known);
+                const WildcardSearchResult wresult =
+                    findWildcardMatch(name, type, options, first_ns,
+                                      last_known);
                 result_status = wresult.code;
                 result_status = wresult.code;
                 result_rrset = wresult.rrset;
                 result_rrset = wresult.rrset;
                 records_found = wresult.records_found;
                 records_found = wresult.records_found;

+ 10 - 9
src/lib/datasrc/database.h

@@ -836,16 +836,16 @@ public:
         /// deriving it from a parent class was deemed not worthwhile.
         /// deriving it from a parent class was deemed not worthwhile.
         struct DelegationSearchResult {
         struct DelegationSearchResult {
             DelegationSearchResult(const ZoneFinder::Result param_code,
             DelegationSearchResult(const ZoneFinder::Result param_code,
-                                   const isc::dns::RRsetPtr param_rrset,
-                                   const isc::dns::RRsetPtr param_ns,
+                                   const isc::dns::ConstRRsetPtr param_rrset,
+                                   const isc::dns::ConstRRsetPtr param_ns,
                                    size_t param_last_known) :
                                    size_t param_last_known) :
                                    code(param_code), rrset(param_rrset),
                                    code(param_code), rrset(param_rrset),
                                    first_ns(param_ns),
                                    first_ns(param_ns),
                                    last_known(param_last_known)
                                    last_known(param_last_known)
             {}
             {}
             const ZoneFinder::Result code;      ///< Result code
             const ZoneFinder::Result code;      ///< Result code
-            const isc::dns::RRsetPtr rrset;     ///< Pointer to RRset found
-            const isc::dns::RRsetPtr first_ns;  ///< Pointer to first NS found
+            const isc::dns::ConstRRsetPtr rrset; ///< Pointer to RRset found
+            const isc::dns::ConstRRsetPtr first_ns; ///< Pointer to first NS found
             const size_t last_known; ///< No. labels in last non-empty domain
             const size_t last_known; ///< No. labels in last non-empty domain
         };
         };
 
 
@@ -865,13 +865,13 @@ public:
         /// deriving it from a parent class was deemed not worthwhile.
         /// deriving it from a parent class was deemed not worthwhile.
         struct WildcardSearchResult {
         struct WildcardSearchResult {
             WildcardSearchResult(const ZoneFinder::Result param_code,
             WildcardSearchResult(const ZoneFinder::Result param_code,
-                                 const isc::dns::RRsetPtr param_rrset,
+                                 const isc::dns::ConstRRsetPtr param_rrset,
                                  const bool param_found) :
                                  const bool param_found) :
                                  code(param_code), rrset(param_rrset),
                                  code(param_code), rrset(param_rrset),
                                  records_found(param_found)
                                  records_found(param_found)
             {}
             {}
             const ZoneFinder::Result code;      ///< Result code
             const ZoneFinder::Result code;      ///< Result code
-            const isc::dns::RRsetPtr rrset;     ///< Pointer to RRset found
+            const isc::dns::ConstRRsetPtr rrset; ///< Pointer to RRset found
             const bool records_found;           ///< true => NXRRSET
             const bool records_found;           ///< true => NXRRSET
         };
         };
 
 
@@ -998,9 +998,10 @@ public:
          *         NXDOMAIN or an NXRRSET.
          *         NXDOMAIN or an NXRRSET.
          */
          */
         WildcardSearchResult
         WildcardSearchResult
-        findWildcardMatch(const isc::dns::Name& name,
-                     const isc::dns::RRType& type, const FindOptions options,
-                     isc::dns::RRsetPtr& first_ns, size_t last_known);
+        findWildcardMatch(
+            const isc::dns::Name& name,
+            const isc::dns::RRType& type, const FindOptions options,
+            const isc::dns::ConstRRsetPtr& first_ns, size_t last_known);
 
 
         /**
         /**
          * \brief Checks if something lives below this domain.
          * \brief Checks if something lives below this domain.