Browse Source

[1183] trivial/minor suggested cleanups: they are mainly indentation,
constify, typo, removing redundant space, etc.

JINMEI Tatuya 13 years ago
parent
commit
954143a274

+ 12 - 14
src/lib/datasrc/database.cc

@@ -185,7 +185,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
     DatabaseAccessor::IteratorContextPtr
         context(database_->getRecords(name, zone_id_));
     // It must not return NULL, that's a bug of the implementation
-    if (context == DatabaseAccessor::IteratorContextPtr()) {
+    if (!context) {
         isc_throw(isc::Unexpected, "Iterator context null at " +
                   name.toText());
     }
@@ -292,7 +292,6 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
     return (std::pair<bool, isc::dns::RRsetPtr>(records_found, result_rrset));
 }
 
-
 ZoneFinder::FindResult
 DatabaseClient::Finder::find(const isc::dns::Name& name,
                              const isc::dns::RRType& type,
@@ -310,30 +309,30 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
         .arg(database_->getDBName()).arg(name).arg(type);
 
     // First, do we have any kind of delegation (NS/DNAME) here?
-    Name origin(getOrigin());
-    size_t origin_label_count(origin.getLabelCount());
-    size_t current_label_count(name.getLabelCount());
+    const Name origin(getOrigin());
+    const size_t origin_label_count(origin.getLabelCount());
+    const size_t current_label_count(name.getLabelCount());
     // This is how many labels we remove to get origin
-    size_t remove_labels(current_label_count - origin_label_count);
+    const size_t remove_labels(current_label_count - origin_label_count);
 
     // Now go trough all superdomains from origin down
     for (int i(remove_labels); i > 0; --i) {
-        Name superdomain(name.split(i));
+        const Name superdomain(name.split(i));
         // Look if there's NS or DNAME (but ignore the NS in origin)
         found = getRRset(superdomain, NULL, false, true,
-                            i != remove_labels && !glue_ok);
+                         i != remove_labels && !glue_ok);
         if (found.second) {
             // We found something redirecting somewhere else
             // (it can be only NS or DNAME here)
             result_rrset = found.second;
             if (result_rrset->getType() == isc::dns::RRType::NS()) {
                 LOG_DEBUG(logger, DBG_TRACE_DETAILED,
-                            DATASRC_DATABASE_FOUND_DELEGATION).
+                          DATASRC_DATABASE_FOUND_DELEGATION).
                     arg(database_->getDBName()).arg(superdomain);
                 result_status = DELEGATION;
             } else {
                 LOG_DEBUG(logger, DBG_TRACE_DETAILED,
-                            DATASRC_DATABASE_FOUND_DNAME).
+                          DATASRC_DATABASE_FOUND_DNAME).
                     arg(database_->getDBName()).arg(superdomain);
                 result_status = DNAME;
             }
@@ -346,18 +345,17 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
         // Try getting the final result and extract it
         // It is special if there's a CNAME or NS, DNAME is ignored here
         // And we don't consider the NS in origin
-        found = getRRset(name, &type, true, false,
-                            name != origin && !glue_ok);
+        found = getRRset(name, &type, true, false, name != origin && !glue_ok);
         records_found = found.first;
         result_rrset = found.second;
         if (result_rrset && name != origin && !glue_ok &&
             result_rrset->getType() == isc::dns::RRType::NS()) {
             LOG_DEBUG(logger, DBG_TRACE_DETAILED,
-                        DATASRC_DATABASE_FOUND_DELEGATION_EXACT).
+                      DATASRC_DATABASE_FOUND_DELEGATION_EXACT).
                 arg(database_->getDBName()).arg(name);
             result_status = DELEGATION;
         } else if (result_rrset && type != isc::dns::RRType::CNAME() &&
-                    result_rrset->getType() == isc::dns::RRType::CNAME()) {
+                   result_rrset->getType() == isc::dns::RRType::CNAME()) {
             result_status = CNAME;
         }
     }

+ 5 - 5
src/lib/datasrc/database.h

@@ -111,11 +111,11 @@ public:
          * Depending on how the iterator was constructed, there is a difference
          * in behaviour; for a 'full zone iterator', created with
          * getAllRecords(), all 5 elements of the array are overwritten.
-         * for a 'name iterator', created with getRecords(), the fifth column
+         * For a 'name iterator', created with getRecords(), the fifth column
          * (NAME_COLUMN) is untouched, since what would be added here is by
          * definition already known to the caller (it already passes it as
          * an argument to getRecords()).
-         * 
+         *
          * \note The order of RRs is not strictly set, but the RRs for single
          * RRset must not be interleaved with any other RRs (eg. RRsets must be
          * "together").
@@ -138,7 +138,7 @@ public:
      * \brief Creates an iterator context for a specific name.
      *
      * This should create a new iterator context to be used by
-     * DatabaseConnection's ZoneIterator. It can be created based on the name
+     * DatabaseAccessor's ZoneIterator. It can be created based on the name
      * or the ID (returned from getZone()), what is more comfortable for the
      * database implementation. Both are provided (and are guaranteed to match,
      * the DatabaseClient first looks up the zone ID and then calls this).
@@ -174,7 +174,7 @@ public:
      * \brief Creates an iterator context for the whole zone.
      *
      * This should create a new iterator context to be used by
-     * DatabaseConnection's ZoneIterator. It can be created based on the name
+     * DatabaseAccessor's ZoneIterator. It can be created based on the name
      * or the ID (returned from getZone()), what is more comfortable for the
      * database implementation. Both are provided (and are guaranteed to match,
      * the DatabaseClient first looks up the zone ID and then calls this).
@@ -201,7 +201,7 @@ public:
 
     /**
      * Definitions of the fields as they are required to be filled in
-     * by getNextRecord()
+     * by IteratorContext::getNext()
      *
      * When implementing getNext(), the columns array should
      * be filled with the values as described in this enumeration,

+ 2 - 2
src/lib/datasrc/sqlite3_accessor.cc

@@ -395,7 +395,7 @@ public:
 
     bool getNext(std::string (&data)[COLUMN_COUNT]) {
         // If there's another row, get it
-        int rc(sqlite3_step(statement_));
+        const int rc(sqlite3_step(statement_));
         if (rc == SQLITE_ROW) {
             // For both types, we copy the first four columns
             copyColumn(data, TYPE_COLUMN);
@@ -452,7 +452,7 @@ private:
         }
     }
 
-    IteratorType iterator_type_;
+    const IteratorType iterator_type_;
     boost::shared_ptr<const SQLite3Database> database_;
     sqlite3_stmt *statement_;
 };

+ 1 - 1
src/lib/datasrc/tests/database_unittest.cc

@@ -245,7 +245,7 @@ public:
 
 private:
     std::map<std::string, std::vector< std::vector<std::string> > > records;
-    // used as temporary storageduring the building of the fake data
+    // used as temporary storage during the building of the fake data
     std::vector< std::vector<std::string> > cur_name;
 
     // Adds one record to the current name in the database