Browse Source

[1062] various types of editorial/trivial fixes.

JINMEI Tatuya 13 years ago
parent
commit
46b961d69a

+ 26 - 21
src/lib/datasrc/database.cc

@@ -12,6 +12,8 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
+#include <vector>
+
 #include <datasrc/database.h>
 
 #include <exceptions/exceptions.h>
@@ -101,7 +103,8 @@ namespace {
         }
         if (rdata_str != "") {
             try {
-                rrset->addRdata(isc::dns::rdata::createRdata(type, cls, rdata_str));
+                rrset->addRdata(isc::dns::rdata::createRdata(type, cls,
+                                                             rdata_str));
             } catch (const isc::dns::rdata::InvalidRdataText& ivrt) {
                 // at this point, rrset may have been initialised for no reason,
                 // and won't be used. But the caller would drop the shared_ptr
@@ -137,13 +140,13 @@ namespace {
 
         // Returns true if this store contains signatures covering the
         // given type
-        bool haveSigsFor(isc::dns::RRType type) {
+        bool haveSigsFor(isc::dns::RRType type) const {
             return (sigs.count(type) > 0);
         }
 
         // If the store contains signatures for the type of the given
         // rrset, they are appended to it.
-        void appendSignatures(isc::dns::RRsetPtr& rrset) {
+        void appendSignatures(isc::dns::RRsetPtr& rrset) const {
             if (haveSigsFor(rrset->getType())) {
                 BOOST_FOREACH(isc::dns::rdata::RdataPtr sig,
                               sigs.find(rrset->getType())->second) {
@@ -180,8 +183,8 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
         }
 
         if (columns.size() != 4) {
-            isc_throw(DataSourceError,
-                      "Datasource backend did not return 4 columns in getNextRecord()");
+            isc_throw(DataSourceError, "Datasource backend did not return 4 "
+                      "columns in getNextRecord()");
         }
 
         try {
@@ -190,33 +193,35 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
             //cur_sigtype(columns[2]);
 
             if (cur_type == type) {
-                addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl, columns[3]);
+                addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
+                            columns[3]);
             } else if (cur_type == isc::dns::RRType::CNAME()) {
                 // There should be no other data, so cur_rrset should be empty,
                 if (result_rrset) {
-                    isc_throw(DataSourceError,
-                                "CNAME found but it is not the only record for " +
-                                name.toText());
+                    isc_throw(DataSourceError, "CNAME found but it is not "
+                              "the only record for " + name.toText());
                 }
-                addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl, columns[3]);
+                addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
+                            columns[3]);
                 result_status = CNAME;
             } else if (cur_type == isc::dns::RRType::RRSIG()) {
-                // If we get signatures before we get the actual data, we can't know
-                // which ones to keep and which to drop...
-                // So we keep a separate store of any signature that may be relevant
-                // and add them to the final RRset when we are done.
-                // A possible optimization here is to not store them for types we
-                // are certain we don't need
+                // If we get signatures before we get the actual data, we
+                // can't know which ones to keep and which to drop...
+                // So we keep a separate store of any signature that may be
+                // relevant and add them to the final RRset when we are done.
+                // A possible optimization here is to not store them for types
+                // we are certain we don't need
                 isc::dns::rdata::RdataPtr cur_rrsig(
-                    isc::dns::rdata::createRdata(cur_type, getClass(), columns[3]));
+                    isc::dns::rdata::createRdata(cur_type, getClass(),
+                                                 columns[3]));
                 sig_store.addSig(cur_rrsig);
             }
         } catch (const isc::dns::InvalidRRType& irt) {
-            isc_throw(DataSourceError,
-                      "Invalid RRType in database for " << name << ": " << columns[0]);
+            isc_throw(DataSourceError, "Invalid RRType in database for " <<
+                      name << ": " << columns[0]);
         } catch (const isc::dns::InvalidRRTTL& irttl) {
-            isc_throw(DataSourceError,
-                      "Invalid TTL in database for " << name << ": " << columns[1]);
+            isc_throw(DataSourceError, "Invalid TTL in database for " <<
+                      name << ": " << columns[1]);
         }
     }
 

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

@@ -65,9 +65,9 @@ public:
     virtual bool getNextRecord(std::vector<std::string>& columns) {
         if (cur_record < cur_name.size()) {
             columns = cur_name[cur_record++];
-            return true;
+            return (true);
         } else {
-            return false;
+            return (false);
         }
     };
 
@@ -268,7 +268,7 @@ TEST_F(DatabaseClientTest, find) {
     shared_ptr<DatabaseClient::Finder> finder(
         dynamic_pointer_cast<DatabaseClient::Finder>(zone.zone_finder));
     EXPECT_EQ(42, finder->zone_id());
-    isc::dns::Name name("www.example.org.");
+    const isc::dns::Name name("www.example.org.");
 
     doFindTest(finder, isc::dns::Name("www.example.org."),
                isc::dns::RRType::A(), isc::dns::RRType::A(),

+ 6 - 5
src/lib/datasrc/tests/sqlite3_connection_unittest.cc

@@ -103,10 +103,11 @@ TEST_F(SQLite3Conn, noClass) {
 }
 
 namespace {
-    // Simple function to cound the number of records for
+    // Simple function to count the number of records for
     // any name
     size_t countRecords(boost::shared_ptr<SQLite3Connection>& conn,
-                        int zone_id, const std::string& name) {
+                        int zone_id, const std::string& name)
+    {
         conn->searchForRecords(zone_id, name);
         size_t count = 0;
         std::vector<std::string> columns;
@@ -114,16 +115,16 @@ namespace {
             EXPECT_EQ(4, columns.size());
             ++count;
         }
-        return count;
+        return (count);
     }
 }
 }
 
 TEST_F(SQLite3Conn, getRecords) {
-    std::pair<bool, int> zone_info(conn->getZone(Name("example.com")));
+    const std::pair<bool, int> zone_info(conn->getZone(Name("example.com")));
     ASSERT_TRUE(zone_info.first);
 
-    int zone_id = zone_info.second;
+    const int zone_id = zone_info.second;
     ASSERT_EQ(1, zone_id);
 
     // without search, getNext() should return false