Parcourir la source

- made lib/dns -Wextra safe.
- introduced new macro UNUSED_PARAM to tell gcc that particular variables are
intentionally unused
- enabled -Wextra by default


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1304 e5f2f494-b856-4b98-b285-d166d9295462

JINMEI Tatuya il y a 15 ans
Parent
commit
3a29ffe4f5

+ 3 - 0
configure.ac

@@ -24,7 +24,9 @@ AM_PATH_PYTHON([3.1])
 # default compiler warning settings
 if test "X$GCC" = "Xyes"; then
 CXXFLAGS="$CXXFLAGS -g -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
+UNUSED_PARAM_ATTRIBUTE='__attribute__((unused))'
 fi
+AC_DEFINE_UNQUOTED(UNUSED_PARAM, $UNUSED_PARAM_ATTRIBUTE, Define to compiler keyword indicating a function argument is intentionally unused)
 
 # produce PIC unless we disable shared libraries. need this for python bindings.
 if test $enable_shared != "no" -a "X$GCC" = "Xyes"; then
@@ -205,6 +207,7 @@ AC_CONFIG_FILES([Makefile
                  src/bin/loadzone/Makefile
                  src/bin/msgq/Makefile
                  src/bin/auth/Makefile
+                 src/bin/auth/tests/Makefile
                  src/bin/xfrin/Makefile
                  src/bin/usermgr/Makefile
                  src/lib/Makefile

+ 1 - 1
src/lib/dns/Makefile.am

@@ -1,6 +1,6 @@
 SUBDIRS = . tests
 
-AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/ext -Wall -Werror
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/ext -Werror
 
 CLEANFILES = *.gcno *.gcda
 CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc

+ 8 - 11
src/lib/dns/message.cc

@@ -225,9 +225,8 @@ public:
 #endif
 
     void init();
-    int parseQuestion(Message& message, InputBuffer& buffer);
-    int parseSection(Message& messge, const Section& section,
-                     InputBuffer& buffer);
+    int parseQuestion(InputBuffer& buffer);
+    int parseSection(const Section& section, InputBuffer& buffer);
 };
 
 MessageImpl::MessageImpl(Message::Mode mode) :
@@ -551,17 +550,17 @@ Message::fromWire(InputBuffer& buffer)
     impl_->counts_[Section::ADDITIONAL().getCode()] = buffer.readUint16();
 
     impl_->counts_[Section::QUESTION().getCode()] =
-        impl_->parseQuestion(*this, buffer);
+        impl_->parseQuestion(buffer);
     impl_->counts_[Section::ANSWER().getCode()] =
-        impl_->parseSection(*this, Section::ANSWER(), buffer);
+        impl_->parseSection(Section::ANSWER(), buffer);
     impl_->counts_[Section::AUTHORITY().getCode()] =
-        impl_->parseSection(*this, Section::AUTHORITY(), buffer);
+        impl_->parseSection(Section::AUTHORITY(), buffer);
     impl_->counts_[Section::ADDITIONAL().getCode()] =
-        impl_->parseSection(*this, Section::ADDITIONAL(), buffer);
+        impl_->parseSection(Section::ADDITIONAL(), buffer);
 }
 
 int
-MessageImpl::parseQuestion(Message& message, InputBuffer& buffer)
+MessageImpl::parseQuestion(InputBuffer& buffer)
 {
     unsigned int added = 0;
 
@@ -605,9 +604,7 @@ struct MatchRR : public unary_function<RRsetPtr, bool> {
 }
 
 int
-MessageImpl::parseSection(Message& message, const Section& section,
-                          InputBuffer& buffer)
-{
+MessageImpl::parseSection(const Section& section, InputBuffer& buffer) {
     unsigned int added = 0;
 
     for (unsigned int count = 0; count < counts_[section.getCode()]; count++) {

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

@@ -187,7 +187,7 @@ Generic::~Generic()
 }
 
 Generic::Generic(const Generic& source) :
-    impl_(new GenericImpl(*source.impl_))
+    Rdata(), impl_(new GenericImpl(*source.impl_))
 {}
 
 Generic&

+ 8 - 7
src/lib/dns/rdata/ch_3/a_1.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include <config.h>             // for UNUSED_PARAM
+
 #include <string>
 
 #include "buffer.h"
@@ -27,29 +29,28 @@ using namespace std;
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
-A::A(const string& addrstr)
+A::A(const string& addrstr UNUSED_PARAM)
 {
     // TBD
 }
 
-A::A(InputBuffer& buffer, size_t rdata_len)
+A::A(InputBuffer& buffer UNUSED_PARAM, size_t rdata_len UNUSED_PARAM)
 {
     // TBD
 }
 
-A::A(const A& source)
-{
+A::A(const A& source UNUSED_PARAM) : Rdata() {
     // TBD
 }
 
 void
-A::toWire(OutputBuffer& buffer) const
+A::toWire(OutputBuffer& buffer UNUSED_PARAM) const
 {
     // TBD
 }
 
 void
-A::toWire(MessageRenderer& renderer) const
+A::toWire(MessageRenderer& renderer UNUSED_PARAM) const
 {
     // TBD
 }
@@ -62,7 +63,7 @@ A::toText() const
 }
 
 int
-A::compare(const Rdata& other) const
+A::compare(const Rdata& other UNUSED_PARAM) const
 {
     return (0);                 // dummy.  TBD
 }

+ 5 - 3
src/lib/dns/rdata/generic/cname_5.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <string>
 
 #include "buffer.h"
@@ -31,15 +33,15 @@ CNAME::CNAME(const std::string& namestr) :
     cname_(namestr)
 {}
 
-CNAME::CNAME(InputBuffer& buffer, size_t rdata_len) :
-    cname_(buffer)
+CNAME::CNAME(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
+    Rdata(), cname_(buffer)
 {
     // we don't need rdata_len for parsing.  if necessary, the caller will
     // check consistency.
 }
 
 CNAME::CNAME(const CNAME& other) :
-    cname_(other.cname_)
+    Rdata(), cname_(other.cname_)
 {}
 
 CNAME::CNAME(const Name& cname) :

+ 4 - 2
src/lib/dns/rdata/generic/dname_39.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include <config.h>
+
 #include <string>
 
 #include "buffer.h"
@@ -31,7 +33,7 @@ DNAME::DNAME(const std::string& namestr) :
     dname_(namestr)
 {}
 
-DNAME::DNAME(InputBuffer& buffer, size_t rdata_len) :
+DNAME::DNAME(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
     dname_(buffer)
 {
     // we don't need rdata_len for parsing.  if necessary, the caller will
@@ -39,7 +41,7 @@ DNAME::DNAME(InputBuffer& buffer, size_t rdata_len) :
 }
 
 DNAME::DNAME(const DNAME& other) :
-    dname_(other.dname_)
+    Rdata(), dname_(other.dname_)
 {}
 
 DNAME::DNAME(const Name& dname) :

+ 3 - 1
src/lib/dns/rdata/generic/dnskey_48.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <iostream>
 #include <string>
 #include <sstream>
@@ -99,7 +101,7 @@ DNSKEY::DNSKEY(InputBuffer& buffer, size_t rdata_len)
 }
 
 DNSKEY::DNSKEY(const DNSKEY& source) :
-    impl_(new DNSKEYImpl(*source.impl_))
+    Rdata(), impl_(new DNSKEYImpl(*source.impl_))
 {}
 
 DNSKEY&

+ 3 - 1
src/lib/dns/rdata/generic/ds_43.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include <config.h>
+
 #include <iostream>
 #include <string>
 #include <sstream>
@@ -94,7 +96,7 @@ DS::DS(InputBuffer& buffer, size_t rdata_len)
 }
 
 DS::DS(const DS& source) :
-    impl_(new DSImpl(*source.impl_))
+    Rdata(), impl_(new DSImpl(*source.impl_))
 {}
 
 DS&

+ 4 - 2
src/lib/dns/rdata/generic/mx_15.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <string>
 
 #include <boost/lexical_cast.hpp>
@@ -31,7 +33,7 @@ using namespace boost;
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
-MX::MX(InputBuffer& buffer, size_t rdata_len) :
+MX::MX(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
     preference_(buffer.readUint16()), mxname_(buffer)
 {
     // we don't need rdata_len for parsing.  if necessary, the caller will
@@ -60,7 +62,7 @@ MX::MX(uint16_t preference, const Name& mxname) :
 {}
 
 MX::MX(const MX& other) :
-    preference_(other.preference_), mxname_(other.mxname_)
+    Rdata(), preference_(other.preference_), mxname_(other.mxname_)
 {}
 
 void

+ 4 - 2
src/lib/dns/rdata/generic/ns_2.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <string>
 
 #include "buffer.h"
@@ -31,7 +33,7 @@ NS::NS(const std::string& namestr) :
     nsname_(namestr)
 {}
 
-NS::NS(InputBuffer& buffer, size_t rdata_len) :
+NS::NS(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
     nsname_(buffer)
 {
     // we don't need rdata_len for parsing.  if necessary, the caller will
@@ -39,7 +41,7 @@ NS::NS(InputBuffer& buffer, size_t rdata_len) :
 }
 
 NS::NS(const NS& other) :
-    nsname_(other.nsname_)
+    Rdata(), nsname_(other.nsname_)
 {}
 
 void

+ 3 - 1
src/lib/dns/rdata/generic/nsec3_50.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <iostream>
 #include <iomanip>
 #include <string>
@@ -171,7 +173,7 @@ NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len)
 }
 
 NSEC3::NSEC3(const NSEC3& source) :
-    impl_(new NSEC3Impl(*source.impl_))
+    Rdata(), impl_(new NSEC3Impl(*source.impl_))
 {}
 
 NSEC3&

+ 3 - 1
src/lib/dns/rdata/generic/nsec3param_51.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <iostream>
 #include <string>
 #include <sstream>
@@ -97,7 +99,7 @@ NSEC3PARAM::NSEC3PARAM(InputBuffer& buffer, size_t rdata_len)
 }
 
 NSEC3PARAM::NSEC3PARAM(const NSEC3PARAM& source) :
-    impl_(new NSEC3PARAMImpl(*source.impl_))
+    Rdata(), impl_(new NSEC3PARAMImpl(*source.impl_))
 {}
 
 NSEC3PARAM&

+ 3 - 1
src/lib/dns/rdata/generic/nsec_47.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <iostream>
 #include <string>
 #include <sstream>
@@ -111,7 +113,7 @@ NSEC::NSEC(InputBuffer& buffer, size_t rdata_len)
 }
 
 NSEC::NSEC(const NSEC& source) :
-    impl_(new NSECImpl(*source.impl_))
+    Rdata(), impl_(new NSECImpl(*source.impl_))
 {}
 
 NSEC&

+ 7 - 4
src/lib/dns/rdata/generic/opt_41.cc

@@ -13,6 +13,9 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+
+#include "config.h"
+
 #include <string>
 
 #include "buffer.h"
@@ -25,7 +28,7 @@ using namespace std;
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
-OPT::OPT(const string& type_str)
+OPT::OPT(const string& type_str UNUSED_PARAM)
 {
     isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text");
 }
@@ -42,7 +45,7 @@ OPT::OPT(InputBuffer& buffer, size_t rdata_len)
     buffer.setPosition(buffer.getPosition() + rdata_len);
 }
 
-OPT::OPT(const OPT& source)
+OPT::OPT(const OPT& source UNUSED_PARAM) : Rdata()
 {
     // there's nothing to copy in this simple implementation.
 }
@@ -54,13 +57,13 @@ OPT::toText() const
 }
 
 void
-OPT::toWire(OutputBuffer& buffer) const
+OPT::toWire(OutputBuffer& buffer UNUSED_PARAM) const
 {
     // nothing to do, as this simple version doesn't support any options.
 }
 
 void
-OPT::toWire(MessageRenderer& renderer) const
+OPT::toWire(MessageRenderer& renderer UNUSED_PARAM) const
 {
     // nothing to do, as this simple version doesn't support any options.
 }

+ 4 - 2
src/lib/dns/rdata/generic/ptr_12.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <string>
 
 #include "buffer.h"
@@ -31,7 +33,7 @@ PTR::PTR(const string& type_str) :
     ptr_name_(type_str)
 {}
 
-PTR::PTR(InputBuffer& buffer, size_t rdata_len) :
+PTR::PTR(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
     ptr_name_(buffer)
 {
     // we don't need rdata_len for parsing.  if necessary, the caller will
@@ -39,7 +41,7 @@ PTR::PTR(InputBuffer& buffer, size_t rdata_len) :
 }
 
 PTR::PTR(const PTR& source) :
-    ptr_name_(source.ptr_name_)
+    Rdata(), ptr_name_(source.ptr_name_)
 {}
 
 std::string

+ 3 - 1
src/lib/dns/rdata/generic/rrsig_46.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <string>
 #include <iomanip>
 #include <iostream>
@@ -137,7 +139,7 @@ RRSIG::RRSIG(InputBuffer& buffer, size_t rdata_len)
 }
 
 RRSIG::RRSIG(const RRSIG& source) :
-    impl_(new RRSIGImpl(*source.impl_))
+    Rdata(), impl_(new RRSIGImpl(*source.impl_))
 {}
 
 RRSIG&

+ 4 - 2
src/lib/dns/rdata/generic/soa_6.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <string>
 
 #include <boost/lexical_cast.hpp>
@@ -31,7 +33,7 @@ using namespace boost;
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
-SOA::SOA(InputBuffer& buffer, size_t rdata_len) :
+SOA::SOA(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
     mname_(buffer), rname_(buffer)
 {
     // we don't need rdata_len for parsing.  if necessary, the caller will
@@ -85,7 +87,7 @@ SOA::SOA(const Name& mname, const Name& rname, uint32_t serial,
 }
 
 SOA::SOA(const SOA& other) :
-    mname_(other.mname_), rname_(other.rname_)
+    Rdata(), mname_(other.mname_), rname_(other.rname_)
 {
     memcpy(numdata_, other.numdata_, sizeof(numdata_));
 }

+ 4 - 2
src/lib/dns/rdata/generic/txt_16.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <stdint.h>
 #include <string.h>
 
@@ -30,7 +32,7 @@ using namespace std;
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
-TXT::TXT(InputBuffer& buffer, size_t rdata_len)
+TXT::TXT(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM)
 {
     uint8_t len;
 
@@ -65,7 +67,7 @@ TXT::TXT(const std::string& txtstr)
 }
 
 TXT::TXT(const TXT& other) :
-    string_list_(other.string_list_)
+    Rdata(), string_list_(other.string_list_)
 {}
 
 void

+ 8 - 6
src/lib/dns/rdata/hs_4/a_1.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include <config.h>             // for UNUSED
+
 #include <string>
 
 #include "buffer.h"
@@ -27,29 +29,29 @@ using namespace std;
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
-A::A(const string& addrstr)
+A::A(const string& addrstr UNUSED_PARAM)
 {
     // TBD
 }
 
-A::A(InputBuffer& buffer, size_t rdata_len)
+A::A(InputBuffer& buffer UNUSED_PARAM, size_t rdata_len UNUSED_PARAM)
 {
     // TBD
 }
 
-A::A(const A& source)
+A::A(const A& source UNUSED_PARAM) : Rdata()
 {
     // TBD
 }
 
 void
-A::toWire(OutputBuffer& buffer) const
+A::toWire(OutputBuffer& buffer UNUSED_PARAM) const
 {
     // TBD
 }
 
 void
-A::toWire(MessageRenderer& renderer) const
+A::toWire(MessageRenderer& renderer UNUSED_PARAM) const
 {
     // TBD
 }
@@ -62,7 +64,7 @@ A::toText() const
 }
 
 int
-A::compare(const Rdata& other) const
+A::compare(const Rdata& other UNUSED_PARAM) const
 {
     return (0);                 // dummy.  TBD
 }

+ 3 - 1
src/lib/dns/rdata/in_1/a_1.cc

@@ -14,6 +14,8 @@
 
 // $Id: rdata.cc 545 2010-01-27 00:33:28Z jinmei $
 
+#include "config.h"
+
 #include <stdint.h>
 #include <string.h>
 
@@ -54,7 +56,7 @@ A::A(InputBuffer& buffer, size_t rdata_len)
 }
 
 A::A(const A& other) :
-    addr_(other.addr_)
+    Rdata(), addr_(other.addr_)
 {}
 
 void

+ 3 - 2
src/lib/dns/rdata/in_1/aaaa_28.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <stdint.h>
 #include <string.h>
 
@@ -49,8 +51,7 @@ AAAA::AAAA(InputBuffer& buffer, size_t rdata_len)
     buffer.readData(&addr_, sizeof(addr_));
 }
 
-AAAA::AAAA(const AAAA& other)
-{
+AAAA::AAAA(const AAAA& other) : Rdata() {
     memcpy(addr_, other.addr_, sizeof(addr_));
 }