Browse Source

[master] Move cppcheck suppressions to the source files (inline)

This fixes a cppcheck regression introduced in commit
48cfa00bb988cfeebab4e6ac7ae440cd685137e5 (I think), which caused line
numbers to change.
Mukund Sivaraman 13 years ago
parent
commit
c1a0b11d84

+ 1 - 1
Makefile.am

@@ -79,7 +79,7 @@ report-coverage: report-cpp-coverage report-python-coverage
 
 # for static C++ check using cppcheck (when available)
 cppcheck:
-	cppcheck --enable=all --suppressions src/cppcheck-suppress.lst \
+	cppcheck --enable=all --suppressions src/cppcheck-suppress.lst --inline-suppr \
 		--quiet --error-exitcode=1 \
 		--template '{file}:{line}: check_fail: {message} ({severity},{id})' \
 		src

+ 8 - 17
src/cppcheck-suppress.lst

@@ -2,21 +2,12 @@
 // the following two will suppress, depending on the cppcheck version
 debug
 missingInclude
-// This is a template, and should be excluded from the check
-unreadVariable:src/lib/dns/rdata/template.cc:61
 
-// 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
-duplicateExpression:src/lib/dns/tests/name_unittest.cc:568
-duplicateExpression:src/lib/dns/tests/name_unittest.cc:579
-
-// 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
-uselessCallsCompare:src/lib/dns/tests/rdata_unittest.cc:253
+// Please don't add any suppressions here. We now use inline
+// suppressions (in the .cc files) so that we don't have to
+// maintain line numbers in this file.
+//
+// See the cppcheck manual for syntax. It is something like:
+//
+//    // cppcheck-suppress duplicateExpression
+//    EXPECT_FALSE(small_name < small_name);

+ 1 - 0
src/lib/dns/rdata/template.cc

@@ -58,6 +58,7 @@ MyType::toWire(AbstractMessageRenderer& renderer) const {
 int
 MyType::compare(const Rdata& other) const {
     // The compare method normally begins with this dynamic cast.
+    // cppcheck-suppress unreadVariable
     const MyType& other_mytype = dynamic_cast<const MyType&>(other);
     // ...
 }

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

@@ -575,6 +575,7 @@ TEST_F(NameTest, lthan) {
     EXPECT_TRUE(small_name < large_name);
 
     EXPECT_FALSE(small_name.lthan(small_name));
+    // cppcheck-suppress duplicateExpression
     EXPECT_FALSE(small_name < small_name);
 
     EXPECT_FALSE(large_name.lthan(small_name));
@@ -586,6 +587,7 @@ TEST_F(NameTest, gthan) {
     EXPECT_TRUE(large_name > small_name);
 
     EXPECT_FALSE(large_name.gthan(large_name));
+    // cppcheck-suppress duplicateExpression
     EXPECT_FALSE(large_name > large_name);
 
     EXPECT_FALSE(small_name.gthan(large_name));

+ 1 - 0
src/lib/dns/tests/rdata_dhcid_unittest.cc

@@ -93,6 +93,7 @@ TEST_F(Rdata_DHCID_Test, getDHCIDDigest) {
 
 TEST_F(Rdata_DHCID_Test, compare) {
     // trivial case: self equivalence
+    // cppcheck-suppress uselessCallsCompare
     EXPECT_EQ(0, rdata_dhcid.compare(rdata_dhcid));
 
     in::DHCID rdata_dhcid1("0YLQvtC/0L7Qu9GPINC00LLQsCDRgNGD0LHQu9GP");

+ 1 - 0
src/lib/dns/tests/rdata_in_a_unittest.cc

@@ -95,6 +95,7 @@ TEST_F(Rdata_IN_A_Test, compare) {
     in::A large2("4.3.2.1");
 
     // trivial case: self equivalence
+    // cppcheck-suppress uselessCallsCompare
     EXPECT_EQ(0, small1.compare(small1));
 
     // confirm these are compared as unsigned values

+ 1 - 0
src/lib/dns/tests/rdata_in_aaaa_unittest.cc

@@ -91,6 +91,7 @@ TEST_F(Rdata_IN_AAAA_Test, compare) {
     in::AAAA large2("8:7:6:5:4:3:2:1");
 
     // trivial case: self equivalence
+    // cppcheck-suppress uselessCallsCompare
     EXPECT_EQ(0, small1.compare(small1));
 
     // confirm these are compared as unsigned values

+ 1 - 0
src/lib/dns/tests/rdata_mx_unittest.cc

@@ -101,6 +101,7 @@ TEST_F(Rdata_MX_Test, compare) {
     generic::MX large2(256, Name("mx.example.com"));
 
     // trivial case: self equivalence
+    // cppcheck-suppress uselessCallsCompare
     EXPECT_EQ(0, small1.compare(small1));
 
     // confirm these are compared as unsigned values

+ 1 - 0
src/lib/dns/tests/rdata_unittest.cc

@@ -250,6 +250,7 @@ TEST_F(Rdata_Unknown_Test, toWireRenderer) {
 
 TEST_F(Rdata_Unknown_Test, compare) {
     // comparison as left-justified unsigned octet sequences:
+    // cppcheck-suppress uselessCallsCompare
     EXPECT_EQ(0, rdata_unknown.compare(rdata_unknown));
 
     generic::Generic rdata_unknown_small("\\# 4 00b2c3ff");

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

@@ -161,6 +161,7 @@ TEST_F(RRTTLTest, lthan) {
     EXPECT_TRUE(ttl_small < ttl_large);
 
     EXPECT_FALSE(ttl_small.lthan(ttl_small));
+    // cppcheck-suppress duplicateExpression
     EXPECT_FALSE(ttl_small < ttl_small);
 
     EXPECT_FALSE(ttl_large.lthan(ttl_small));
@@ -172,6 +173,7 @@ TEST_F(RRTTLTest, gthan) {
     EXPECT_TRUE(ttl_large > ttl_small);
 
     EXPECT_FALSE(ttl_large.gthan(ttl_large));
+    // cppcheck-suppress duplicateExpression
     EXPECT_FALSE(ttl_large > ttl_large);
 
     EXPECT_FALSE(ttl_small.gthan(ttl_large));