Browse Source

[master] Merge branch 'trac1193'

Jelte Jansen 13 years ago
parent
commit
56b495e4bd

+ 13 - 5
src/cppcheck-suppress.lst

@@ -4,8 +4,16 @@ debug
 missingInclude
 // This is a template, and should be excluded from the check
 unreadVariable:src/lib/dns/rdata/template.cc:61
-// Intentional self assignment tests.  Suppress warning about them.
-selfAssignment:src/lib/dns/tests/name_unittest.cc:293
-selfAssignment:src/lib/dns/tests/rdata_unittest.cc:228
-selfAssignment:src/lib/dns/tests/tsigkey_unittest.cc:137
-selfAssignment:src/lib/dns/tests/rdata_txt_like_unittest.cc:222
+
+// Intentional self-comparisons
+duplicateExpression:src/lib/dns/tests/name_unittest.cc:569
+duplicateExpression:src/lib/dns/tests/name_unittest.cc:580
+duplicateExpression:src/lib/dns/tests/rrttl_unittest.cc:164
+duplicateExpression:src/lib/dns/tests/rrttl_unittest.cc:175
+
+// Intentional self-comparisons
+uselessCallsCompare:src/lib/dns/tests/rdata_dhcid_unittest.cc:96
+uselessCallsCompare:src/lib/dns/tests/rdata_in_a_unittest.cc:98
+uselessCallsCompare:src/lib/dns/tests/rdata_in_aaaa_unittest.cc:94
+uselessCallsCompare:src/lib/dns/tests/rdata_mx_unittest.cc:104
+uselessCallsCompare:src/lib/dns/tests/rdata_unittest.cc:254

+ 0 - 1
src/lib/config/module_spec.cc

@@ -466,7 +466,6 @@ ModuleSpec::validateSpecList(ConstElementPtr spec, ConstElementPtr data,
                                const bool full, ElementPtr errors) const
 {
     bool validated = true;
-    std::string cur_item_name;
     BOOST_FOREACH(ConstElementPtr cur_spec_el, spec->listValue()) {
         if (!validateSpec(cur_spec_el, data, full, errors)) {
             validated = false;

+ 0 - 1
src/lib/datasrc/memory_datasrc.cc

@@ -1328,7 +1328,6 @@ checkConfig(ConstElementPtr config, ElementPtr errors) {
     }
 
     return (result);
-    return true;
 }
 
 } // end anonymous namespace

+ 2 - 2
src/lib/dhcp/iface_mgr.cc

@@ -130,7 +130,7 @@ IfaceMgr::IfaceMgr()
         // interface detection is implemented. Otherwise
         // it is not possible to run tests in a portable
         // way (see detectIfaces() method).
-        throw ex;
+        throw;
     }
 }
 
@@ -191,7 +191,7 @@ IfaceMgr::stubDetectIfaces() {
 
         // TODO Do LOG_FATAL here
         std::cerr << "Interface detection failed." << std::endl;
-        throw ex;
+        throw;
     }
 }
 

+ 2 - 1
src/lib/dns/python/message_python.cc

@@ -377,8 +377,9 @@ Message_getTSIGRecord(s_Message* self) {
 
         if (tsig_record == NULL) {
             Py_RETURN_NONE;
+        } else {
+            return (createTSIGRecordObject(*tsig_record));
         }
-        return (createTSIGRecordObject(*tsig_record));
     } catch (const InvalidMessageOperation& ex) {
         PyErr_SetString(po_InvalidMessageOperation, ex.what());
     } catch (const exception& ex) {

+ 2 - 2
src/lib/dns/tests/name_unittest.cc

@@ -543,7 +543,7 @@ TEST_F(NameTest, leq) {
 
     // small <= small is true
     EXPECT_TRUE(small_name.leq(small_name));
-    EXPECT_TRUE(small_name <= small_name);
+    EXPECT_LE(small_name, small_name);
 
     // large <= small is false
     EXPECT_FALSE(large_name.leq(small_name));
@@ -555,7 +555,7 @@ TEST_F(NameTest, geq) {
     EXPECT_TRUE(large_name >= small_name);
 
     EXPECT_TRUE(large_name.geq(large_name));
-    EXPECT_TRUE(large_name >= large_name);
+    EXPECT_GE(large_name, large_name);
 
     EXPECT_FALSE(small_name.geq(large_name));
     EXPECT_FALSE(small_name >= large_name);

+ 2 - 2
src/lib/dns/tests/rrttl_unittest.cc

@@ -138,7 +138,7 @@ TEST_F(RRTTLTest, leq) {
 
     // small <= small is true
     EXPECT_TRUE(ttl_small.leq(ttl_small));
-    EXPECT_TRUE(ttl_small <= ttl_small);
+    EXPECT_LE(ttl_small, ttl_small);
 
     // large <= small is false
     EXPECT_FALSE(ttl_large.leq(ttl_small));
@@ -150,7 +150,7 @@ TEST_F(RRTTLTest, geq) {
     EXPECT_TRUE(ttl_large >= ttl_small);
 
     EXPECT_TRUE(ttl_large.geq(ttl_large));
-    EXPECT_TRUE(ttl_large >= ttl_large);
+    EXPECT_GE(ttl_large, ttl_large);
 
     EXPECT_FALSE(ttl_small.geq(ttl_large));
     EXPECT_FALSE(ttl_small >= ttl_large);

+ 2 - 2
src/lib/nsas/glue_hints.cc

@@ -86,8 +86,8 @@ GlueHints::GlueHints(const std::string& zone_name,
 
 bool
 GlueHints::hasGlue(AddressFamily family) const {
-    return ((addresses_v4.size() > 0 && (family == ANY_OK || family == V4_ONLY)) ||
-            (addresses_v6.size() > 0 && (family == ANY_OK || family == V6_ONLY)));
+    return ((!addresses_v4.empty() && (family == ANY_OK || family == V4_ONLY)) ||
+            (!addresses_v6.empty() && (family == ANY_OK || family == V6_ONLY)));
 }
 
 NameserverAddress

+ 1 - 1
src/lib/nsas/hash_table.h

@@ -59,7 +59,7 @@ struct HashTableSlot {
     /// \brief Copy Constructor
     ///
     /// ... which as noted in the class description does not copy.
-    HashTableSlot(const HashTableSlot<T>&)
+    HashTableSlot(const HashTableSlot<T>&) : mutex_(), list_()
     { }
 
 public:

+ 2 - 2
src/lib/nsas/tests/nameserver_entry_unittest.cc

@@ -139,7 +139,7 @@ TEST_F(NameserverEntryTest, SetRTT) {
     NameserverEntry::AddressVector vec;
     alpha->getAddresses(vec);
 
-    ASSERT_TRUE(vec.size() > 0);
+    ASSERT_FALSE(vec.empty());
 
     // Take the first address and change the RTT.
     IOAddress first_address = vec[0].getAddress();
@@ -174,7 +174,7 @@ TEST_F(NameserverEntryTest, Unreachable) {
     NameserverEntry::AddressVector vec;
     alpha->getAddresses(vec);
 
-    ASSERT_TRUE(vec.size() > 0);
+    ASSERT_FALSE(vec.empty());
 
     // Take the first address and mark as unreachable.
     IOAddress first_address = vec[0].getAddress();

+ 1 - 1
src/lib/nsas/zone_entry.cc

@@ -329,7 +329,7 @@ updateAddressSelector(std::vector<NameserverAddress>& addresses,
                 it != probabilities.end(); ++it){
             (*it) /= sum;
         }
-    } else if(probabilities.size() > 0){
+    } else if(!probabilities.empty()){
         // If all the nameservers are unreachable, the sum will be 0
         // So give each server equal opportunity to be selected.
         for(vector<double>::iterator it = probabilities.begin();