Browse Source

hide UNUSED_PARAM attributes in .cc, not .h as it wouldn't be good to
include "config.h" in public header files.


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

JINMEI Tatuya 15 years ago
parent
commit
d8a28660b6

+ 74 - 11
src/lib/auth/data_source.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include <cassert>
 #include <iomanip>
 #include <iostream>
@@ -893,29 +895,90 @@ Nsec3Param::getHash(const Name& name) const {
     uint8_t digest[SHA1_HASHSIZE];
     uint8_t* input = (uint8_t*) buf.getData();
     size_t inlength = buf.getLength();
-    uint8_t saltlen = salt_.size();
-    uint8_t salt[saltlen];
-    for (int i = 0; i < saltlen; ++i) {
-        salt[i] = salt_[i];
-    }
+    const uint8_t saltlen = salt_.size();
 
     int n = 0;
     SHA1Context sha;
     do {
         SHA1Reset(&sha);
         SHA1Input(&sha, input, inlength);
-        SHA1Input(&sha, salt, saltlen);
+        SHA1Input(&sha, &salt_[0], saltlen);
         SHA1Result(&sha, digest);
         input = digest;
         inlength = SHA1_HASHSIZE;
     } while (n++ < iterations_);
 
-    vector<uint8_t> result;
-    for (int i = 0; i < SHA1_HASHSIZE; ++i) {
-        result.push_back(digest[i]);
-    }
+    return (encodeBase32(vector<uint8_t>(digest, digest + SHA1_HASHSIZE)));
+}
+
+//
+// The following methods are effectively empty, and their parameters are
+// unused.  To silence compilers that warn unused function parameters,
+// we specify a (compiler dependent) special keyword when available.
+// It's defined in config.h, and to avoid including this header file from
+// installed files we define the methods here.
+//
+DataSrc::Result
+DataSrc::init(const isc::data::ElementPtr config UNUSED_PARAM) {
+    return NOT_IMPLEMENTED;
+}
+
+DataSrc::Result
+MetaDataSrc::findRRset(const isc::dns::Name& qname UNUSED_PARAM,
+                       const isc::dns::RRClass& qclass UNUSED_PARAM,
+                       const isc::dns::RRType& qtype UNUSED_PARAM,
+                       isc::dns::RRsetList& target UNUSED_PARAM,
+                       uint32_t& flags UNUSED_PARAM,
+                       const isc::dns::Name* zonename UNUSED_PARAM) const
+{
+    return (NOT_IMPLEMENTED);
+}
 
-    return (encodeBase32(result));
+DataSrc::Result
+MetaDataSrc::findExactRRset(const isc::dns::Name& qname UNUSED_PARAM,
+                            const isc::dns::RRClass& qclass UNUSED_PARAM,
+                            const isc::dns::RRType& qtype UNUSED_PARAM,
+                            isc::dns::RRsetList& target UNUSED_PARAM,
+                            uint32_t& flags UNUSED_PARAM,
+                            const isc::dns::Name* zonename UNUSED_PARAM) const
+{
+    return (NOT_IMPLEMENTED);
+}
+
+DataSrc::Result
+MetaDataSrc::findAddrs(const isc::dns::Name& qname UNUSED_PARAM,
+                       const isc::dns::RRClass& qclass UNUSED_PARAM,
+                       isc::dns::RRsetList& target UNUSED_PARAM,
+                       uint32_t& flags UNUSED_PARAM,
+                       const isc::dns::Name* zonename UNUSED_PARAM) const
+{
+    return (NOT_IMPLEMENTED);
+}
+
+DataSrc::Result
+MetaDataSrc::findReferral(const isc::dns::Name& qname UNUSED_PARAM,
+                          const isc::dns::RRClass& qclass UNUSED_PARAM,
+                          isc::dns::RRsetList& target UNUSED_PARAM,
+                          uint32_t& flags UNUSED_PARAM,
+                          const isc::dns::Name* zonename UNUSED_PARAM) const
+{
+    return (NOT_IMPLEMENTED);
+}
+
+DataSrc::Result
+MetaDataSrc::findPreviousName(const isc::dns::Name& qname UNUSED_PARAM,
+                              isc::dns::Name& target UNUSED_PARAM,
+                              const isc::dns::Name* zonename UNUSED_PARAM) const
+{
+    return (NOT_IMPLEMENTED);
+}
+
+DataSrc::Result
+MetaDataSrc::findCoveringNSEC3(const isc::dns::Name& zonename UNUSED_PARAM,
+                               std::string& hash UNUSED_PARAM,
+                               isc::dns::RRsetList& target UNUSED_PARAM) const
+{
+    return (NOT_IMPLEMENTED);
 }
 
 }

+ 34 - 57
src/lib/auth/data_source.h

@@ -17,8 +17,6 @@
 #ifndef __DATA_SOURCE_H
 #define __DATA_SOURCE_H
 
-#include "config.h"
-
 #include <stdint.h>
 
 #include <vector>
@@ -190,8 +188,7 @@ public:
     void setClass(const isc::dns::RRClass& c) { rrclass = c; }
 
     Result init() { return NOT_IMPLEMENTED; }
-    Result init(const isc::data::ElementPtr config UNUSED_PARAM)
-    { return NOT_IMPLEMENTED; }
+    Result init(const isc::data::ElementPtr config);
     Result close() { return NOT_IMPLEMENTED; }
 
     virtual Result findRRset(const isc::dns::Name& qname,
@@ -263,59 +260,39 @@ public:
     // to get a pointer to the best concrete data source for the specified
     // zone, then send all queries directly to that data source.
 
-    Result findRRset(const isc::dns::Name& qname UNUSED_PARAM,
-                     const isc::dns::RRClass& qclass UNUSED_PARAM,
-                     const isc::dns::RRType& qtype UNUSED_PARAM,
-                     isc::dns::RRsetList& target UNUSED_PARAM,
-                     uint32_t& flags UNUSED_PARAM,
-                     const isc::dns::Name* zonename UNUSED_PARAM) const
-    {
-        return (NOT_IMPLEMENTED);
-    }
-
-    Result findExactRRset(const isc::dns::Name& qname UNUSED_PARAM,
-                          const isc::dns::RRClass& qclass UNUSED_PARAM,
-                          const isc::dns::RRType& qtype UNUSED_PARAM,
-                          isc::dns::RRsetList& target UNUSED_PARAM,
-                          uint32_t& flags UNUSED_PARAM,
-                          const isc::dns::Name* zonename UNUSED_PARAM) const
-    {
-        return (NOT_IMPLEMENTED);
-    }
-
-    Result findAddrs(const isc::dns::Name& qname UNUSED_PARAM,
-                     const isc::dns::RRClass& qclass UNUSED_PARAM,
-                     isc::dns::RRsetList& target UNUSED_PARAM,
-                     uint32_t& flags UNUSED_PARAM,
-                     const isc::dns::Name* zonename UNUSED_PARAM) const
-    {
-        return (NOT_IMPLEMENTED);
-    }
-
-    Result findReferral(const isc::dns::Name& qname UNUSED_PARAM,
-                        const isc::dns::RRClass& qclass UNUSED_PARAM,
-                        isc::dns::RRsetList& target UNUSED_PARAM,
-                        uint32_t& flags UNUSED_PARAM,
-                        const isc::dns::Name* zonename UNUSED_PARAM) const
-    {
-        return (NOT_IMPLEMENTED);
-    }
-
-    virtual Result findPreviousName(
-        const isc::dns::Name& qname UNUSED_PARAM,
-        isc::dns::Name& target UNUSED_PARAM,
-        const isc::dns::Name* zonename UNUSED_PARAM) const
-    {
-        return (NOT_IMPLEMENTED);
-    }
-
-   virtual Result findCoveringNSEC3(
-       const isc::dns::Name& zonename UNUSED_PARAM,
-       std::string& hash UNUSED_PARAM,
-       isc::dns::RRsetList& target UNUSED_PARAM) const
-   {
-       return (NOT_IMPLEMENTED);
-   }
+    Result findRRset(const isc::dns::Name& qname,
+                     const isc::dns::RRClass& qclass,
+                     const isc::dns::RRType& qtype,
+                     isc::dns::RRsetList& target,
+                     uint32_t& flags,
+                     const isc::dns::Name* zonename) const;
+
+    Result findExactRRset(const isc::dns::Name& qname,
+                          const isc::dns::RRClass& qclass,
+                          const isc::dns::RRType& qtype,
+                          isc::dns::RRsetList& target,
+                          uint32_t& flags,
+                          const isc::dns::Name* zonename) const;
+
+    Result findAddrs(const isc::dns::Name& qname,
+                     const isc::dns::RRClass& qclass,
+                     isc::dns::RRsetList& target,
+                     uint32_t& flags,
+                     const isc::dns::Name* zonename) const;
+
+    Result findReferral(const isc::dns::Name& qname,
+                        const isc::dns::RRClass& qclass,
+                        isc::dns::RRsetList& target,
+                        uint32_t& flags,
+                        const isc::dns::Name* zonename) const;
+
+    virtual Result findPreviousName(const isc::dns::Name& qname,
+                                    isc::dns::Name& target,
+                                    const isc::dns::Name* zonename) const;
+
+   virtual Result findCoveringNSEC3(const isc::dns::Name& zonename,
+                                    std::string& hash,
+                                    isc::dns::RRsetList& target) const;
 
 private:
     std::vector<ConstDataSrcPtr> data_sources;

+ 9 - 4
src/lib/auth/static_datasrc.cc

@@ -251,14 +251,19 @@ StaticDataSrc::findCoveringNSEC3(const Name& zonename UNUSED_PARAM,
 }
 
 DataSrc::Result
-StaticDataSrc::init()
-{
+StaticDataSrc::init() {
     return (SUCCESS);
 }
 
+// Static data source is "configuration less", so the \c config parameter
+// is intentionally ignored.
 DataSrc::Result
-StaticDataSrc::close()
-{
+StaticDataSrc::init(const isc::data::ElementPtr config UNUSED_PARAM) {
+    return init();
+}
+
+DataSrc::Result
+StaticDataSrc::close() {
     return (SUCCESS);
 }
 

+ 1 - 4
src/lib/auth/static_datasrc.h

@@ -84,10 +84,7 @@ public:
                             isc::dns::RRsetList& target) const;
 
     Result init();
-    // Static data source is "configuration less", so the \c config parameter
-    // is intentionally ignored.
-    Result init(const isc::data::ElementPtr config UNUSED_PARAM)
-    { return init(); };
+    Result init(const isc::data::ElementPtr config);
     Result close();
 private:
     StaticDataSrcImpl* impl_;

+ 131 - 1
src/lib/cc/data.cc

@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include "config.h"
+
 #include "data.h"
 
 #include <cstdio>
@@ -24,8 +26,8 @@
 #include <boost/algorithm/string.hpp> // for iequals
 
 using namespace std;
-using namespace isc::data;
 
+namespace {
 const unsigned char PROTOCOL_VERSION[4] = { 0x53, 0x6b, 0x61, 0x6e };
 
 const unsigned char ITEM_BLOB = 0x01;
@@ -42,10 +44,138 @@ const unsigned char ITEM_LENGTH_32   = 0x00;
 const unsigned char ITEM_LENGTH_16   = 0x10;
 const unsigned char ITEM_LENGTH_8    = 0x20;
 const unsigned char ITEM_LENGTH_MASK = 0x30;
+}
 
 namespace isc {
 namespace data {
 
+//
+// The following methods are effectively empty, and their parameters are
+// unused.  To silence compilers that warn unused function parameters,
+// we specify a (compiler dependent) special keyword when available.
+// It's defined in config.h, and to avoid including this header file from
+// installed files we define the methods here.
+//
+bool
+Element::getValue(int& t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::getValue(double& t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::getValue(bool& t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::getValue(std::string& t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::getValue(std::vector<ElementPtr>& t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::getValue(std::map<std::string, ElementPtr>& t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::setValue(const int v UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::setValue(const double v UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::setValue(const bool t UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::setValue(const std::string& v UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::setValue(const std::vector<ElementPtr>& v UNUSED_PARAM) {
+    return false;
+}
+
+bool
+Element::setValue(const std::map<std::string, ElementPtr>& v UNUSED_PARAM)
+{
+    return false;
+}
+
+ElementPtr
+Element::get(const int i UNUSED_PARAM) {
+    isc_throw(TypeError, "get(int) called on a non-list Element");
+}
+
+void
+Element::set(const size_t i UNUSED_PARAM, ElementPtr element UNUSED_PARAM) {
+    isc_throw(TypeError, "set(int, element) called on a non-list Element");
+}
+
+void
+Element::add(ElementPtr element UNUSED_PARAM) {
+    isc_throw(TypeError, "add() called on a non-list Element");
+}
+
+void
+Element::remove(const int i UNUSED_PARAM) {
+    isc_throw(TypeError, "remove(int) called on a non-list Element");
+}
+
+size_t
+Element::size() {
+    isc_throw(TypeError, "size() called on a non-list Element");
+}
+
+ElementPtr
+Element::get(const std::string& name UNUSED_PARAM) {
+    isc_throw(TypeError, "get(string) called on a non-map Element");
+}
+
+void
+Element::set(const std::string& name UNUSED_PARAM,
+             ElementPtr element UNUSED_PARAM)
+{
+    isc_throw(TypeError, "set(name, element) called on a non-map Element");
+}
+
+void
+Element::remove(const std::string& name UNUSED_PARAM) {
+    isc_throw(TypeError, "remove(string) called on a non-map Element");
+}
+
+bool
+Element::contains(const std::string& name UNUSED_PARAM) {
+    isc_throw(TypeError, "contains(string) called on a non-map Element");
+}
+
+ElementPtr
+Element::find(const std::string& identifier UNUSED_PARAM) {
+    isc_throw(TypeError, "find(string) called on a non-map Element");
+}
+
+bool
+Element::find(const std::string& identifier UNUSED_PARAM,
+              ElementPtr& t UNUSED_PARAM)
+{
+    return false;
+}
+
 namespace {
 inline void
 throwParseError(const std::string& error, const std::string& file, int line = 0, int pos = 0)

+ 23 - 43
src/lib/cc/data.h

@@ -17,8 +17,6 @@
 #ifndef _ISC_DATA_H
 #define _ISC_DATA_H 1
 
-#include "config.h"
-
 #include <string>
 #include <vector>
 #include <map>
@@ -157,14 +155,12 @@ public:
     /// data to the given reference and returning true
     ///
     //@{
-    virtual bool getValue(int& t UNUSED_PARAM) { return false; };
-    virtual bool getValue(double& t UNUSED_PARAM) { return false; };
-    virtual bool getValue(bool& t UNUSED_PARAM) { return false; };
-    virtual bool getValue(std::string& t UNUSED_PARAM) { return false; };
-    virtual bool getValue(std::vector<ElementPtr>& t UNUSED_PARAM)
-    { return false; };
-    virtual bool getValue(std::map<std::string, ElementPtr>& t UNUSED_PARAM)
-    { return false; };
+    virtual bool getValue(int& t);
+    virtual bool getValue(double& t);
+    virtual bool getValue(bool& t);
+    virtual bool getValue(std::string& t);
+    virtual bool getValue(std::vector<ElementPtr>& t);
+    virtual bool getValue(std::map<std::string, ElementPtr>& t);
     //@}
     ///
     /// \name Exception-safe setters.
@@ -174,15 +170,12 @@ public:
     /// is of the correct type
     ///
     //@{
-    virtual bool setValue(const int v UNUSED_PARAM) { return false; };
-    virtual bool setValue(const double v UNUSED_PARAM) { return false; };
-    virtual bool setValue(const bool t UNUSED_PARAM) { return false; };
-    virtual bool setValue(const std::string& v UNUSED_PARAM) { return false; };
-    virtual bool setValue(const std::vector<ElementPtr>& v UNUSED_PARAM)
-    { return false; };
-    virtual bool setValue(const std::map<std::string,
-                          ElementPtr>& v UNUSED_PARAM)
-    { return false; };
+    virtual bool setValue(const int v);
+    virtual bool setValue(const double v);
+    virtual bool setValue(const bool t);
+    virtual bool setValue(const std::string& v);
+    virtual bool setValue(const std::vector<ElementPtr>& v);
+    virtual bool setValue(const std::map<std::string, ElementPtr>& v);
     //@}
 
 
@@ -197,26 +190,21 @@ public:
     /// Returns the ElementPtr at the given index. If the index is out
     /// of bounds, this function throws an std::out_of_range exception.
     /// \param i The position of the ElementPtr to return
-    virtual ElementPtr get(const int i UNUSED_PARAM)
-    { isc_throw(TypeError, "get(int) called on a non-list Element"); };
+    virtual ElementPtr get(const int i);
     /// Sets the ElementPtr at the given index. If the index is out
     /// of bounds, this function throws an std::out_of_range exception.
     /// \param i The position of the ElementPtr to set
     /// \param element The ElementPtr to set at the position
-    virtual void set(const size_t i UNUSED_PARAM,
-                     ElementPtr element UNUSED_PARAM)
-    { isc_throw(TypeError, "set(int, element) called on a non-list Element"); };
+    virtual void set(const size_t i, ElementPtr element);
     /// Adds an ElementPtr to the list
     /// \param element The ElementPtr to add
-    virtual void add(ElementPtr element UNUSED_PARAM)
-    { isc_throw(TypeError, "add() called on a non-list Element"); };
+    virtual void add(ElementPtr element);
     /// Removes the element at the given position. If the index is out
     /// of nothing happens.
     /// \param i The index of the element to remove.
-    virtual void remove(const int i UNUSED_PARAM)
-    { isc_throw(TypeError, "remove(int) called on a non-list Element"); };
+    virtual void remove(const int i);
     /// Returns the number of elements in the list.
-    virtual size_t size() { isc_throw(TypeError, "size() called on a non-list Element"); };
+    virtual size_t size();
     //@}
     
     /// \name MapElement functions
@@ -227,22 +215,17 @@ public:
     /// Returns the ElementPtr at the given key
     /// \param name The key of the Element to return
     /// \return The ElementPtr at the given key
-    virtual ElementPtr get(const std::string& name UNUSED_PARAM)
-    { isc_throw(TypeError, "get(string) called on a non-map Element"); } ;
+    virtual ElementPtr get(const std::string& name);
     /// Sets the ElementPtr at the given key
     /// \param name The key of the Element to set
-    virtual void set(const std::string& name UNUSED_PARAM,
-                     ElementPtr element UNUSED_PARAM)
-    { isc_throw(TypeError, "set(name, element) called on a non-map Element"); };
+    virtual void set(const std::string& name, ElementPtr element);
     /// Remove the ElementPtr at the given key
     /// \param name The key of the Element to remove
-    virtual void remove(const std::string& name UNUSED_PARAM)
-    { isc_throw(TypeError, "remove(string) called on a non-map Element"); };
+    virtual void remove(const std::string& name);
     /// Checks if there is data at the given key
     /// \param name The key of the Element to remove
     /// \return true if there is data at the key, false if not.
-    virtual bool contains(const std::string& name UNUSED_PARAM)
-    { isc_throw(TypeError, "contains(string) called on a non-map Element"); }
+    virtual bool contains(const std::string& name);
     /// Recursively finds any data at the given identifier. The
     /// identifier is a /-separated list of names of nested maps, with
     /// the last name being the leaf that is returned.
@@ -256,15 +239,12 @@ public:
     /// \return The ElementPtr at the given identifier. Returns a
     /// null ElementPtr if it is not found, which can be checked with
     /// Element::is_null(ElementPtr e).
-    virtual ElementPtr find(const std::string& identifier UNUSED_PARAM)
-    { isc_throw(TypeError, "find(string) called on a non-map Element"); };
+    virtual ElementPtr find(const std::string& identifier);
     /// See \c Element::find()
     /// \param identifier The identifier of the element to find
     /// \param t Reference to store the resulting ElementPtr, if found.
     /// \return true if the element was found, false if not.
-    virtual bool find(const std::string& identifier UNUSED_PARAM,
-                      ElementPtr& t UNUSED_PARAM)
-    { return false; };
+    virtual bool find(const std::string& identifier, ElementPtr& t);
     //@}
 
     /// \name Factory functions

+ 2 - 0
src/lib/config/tests/ccsession_unittests.cc

@@ -14,6 +14,8 @@
 
 // $Id: module_spec_unittests.cc 1321 2010-03-11 10:17:03Z jelte $
 
+#include "config.h"
+
 #include <gtest/gtest.h>
 
 #include "fake_session.h"