BIND 10 trac2433, updated. 46efce68984c6ab8c5d02618e2b9ca21bf46de06 [2433] Remove unnecessary wrapper function

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jan 4 12:33:56 UTC 2013


The branch, trac2433 has been updated
       via  46efce68984c6ab8c5d02618e2b9ca21bf46de06 (commit)
       via  7bea86f90950a22f72d0c6271d7086ab59abdfa0 (commit)
       via  1f011110511b06ca175f19fecf0ce522140c6f95 (commit)
      from  2d107bd1f98f6a3aed2120213d713111246e6535 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 46efce68984c6ab8c5d02618e2b9ca21bf46de06
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Jan 4 13:32:28 2013 +0100

    [2433] Remove unnecessary wrapper function
    
    The method can be called by boost::bind directly.

commit 7bea86f90950a22f72d0c6271d7086ab59abdfa0
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Jan 4 13:27:18 2013 +0100

    [2433] Avoid copy of the callbacks
    
    When passing an argument to boost::bind by value, it was copied
    (obviously, since it allowed removal of const). Add the const and use a
    pointer to avoid the copy of possibly large object.

commit 1f011110511b06ca175f19fecf0ce522140c6f95
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Jan 4 13:24:08 2013 +0100

    [2433] Make the zone checker test compile
    
    GCC requires the method passed to boost::bind to be public (not sure if
    it is a bug or required by standard, but this way it compiles and it
    doesn't expose anything anyway, since the class definition is in .cc).

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/tests/zone_checker_unittest.cc |    2 ++
 src/lib/dns/zone_checker.cc                |   15 +++++----------
 src/lib/dns/zone_checker.h                 |    4 ++--
 3 files changed, 9 insertions(+), 12 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/tests/zone_checker_unittest.cc b/src/lib/dns/tests/zone_checker_unittest.cc
index eb0f750..9a10f34 100644
--- a/src/lib/dns/tests/zone_checker_unittest.cc
+++ b/src/lib/dns/tests/zone_checker_unittest.cc
@@ -63,6 +63,7 @@ protected:
         rrsets_.reset(new RRsetCollection(ss, zname_, zclass_));
     }
 
+public:
     void callback(const std::string& reason, bool is_error) {
         if (is_error) {
             errors_.push_back(reason);
@@ -71,6 +72,7 @@ protected:
         }
     }
 
+protected:
     // Check stored issue messages with expected ones.  Clear vectors so
     // the caller can check other cases.
     void checkIssues() {
diff --git a/src/lib/dns/zone_checker.cc b/src/lib/dns/zone_checker.cc
index 15ee296..aa307d2 100644
--- a/src/lib/dns/zone_checker.cc
+++ b/src/lib/dns/zone_checker.cc
@@ -167,18 +167,13 @@ checkNS(const Name& zone_name, const RRClass& zone_class,
     checkNSNames(zone_name, zone_class, zone_rrsets, rrset, callbacks);
 }
 
-// The following two are simple wrapper of checker callbacks so checkZone()
+// The following is a simple wrapper of checker callback so checkZone()
 // can also remember any critical errors.
 void
-errorWrapper(const string& reason, ZoneCheckerCallbacks& callbacks,
+errorWrapper(const string& reason, const ZoneCheckerCallbacks* callbacks,
              bool* had_error) {
     *had_error = true;
-    callbacks.error(reason);
-}
-
-void
-warnWrapper(const string& reason, ZoneCheckerCallbacks& callbacks) {
-    callbacks.warn(reason);
+    callbacks->error(reason);
 }
 }
 
@@ -188,8 +183,8 @@ checkZone(const Name& zone_name, const RRClass& zone_class,
           const ZoneCheckerCallbacks& callbacks) {
     bool had_error = false;
     ZoneCheckerCallbacks my_callbacks(
-        boost::bind(errorWrapper, _1, callbacks, &had_error),
-        boost::bind(warnWrapper, _1, callbacks));
+        boost::bind(errorWrapper, _1, &callbacks, &had_error),
+        boost::bind(&ZoneCheckerCallbacks::warn, &callbacks, _1));
 
     checkSOA(zone_name, zone_class, zone_rrsets, my_callbacks);
     checkNS(zone_name, zone_class, zone_rrsets, my_callbacks);
diff --git a/src/lib/dns/zone_checker.h b/src/lib/dns/zone_checker.h
index 76deb1e..dfb4946 100644
--- a/src/lib/dns/zone_checker.h
+++ b/src/lib/dns/zone_checker.h
@@ -59,7 +59,7 @@ public:
     /// thrown from the callback.
     ///
     /// \param reason Textual representation of the reason for the error.
-    void error(const std::string& reason) {
+    void error(const std::string& reason) const {
         if (!error_callback_.empty()) {
             error_callback_(reason);
         }
@@ -71,7 +71,7 @@ public:
     /// thrown from the callback.
     ///
     /// \param reason Textual representation of the reason for the issue.
-    void warn(const std::string& reason) {
+    void warn(const std::string& reason) const {
         if (!warn_callback_.empty())
             warn_callback_(reason);
     }



More information about the bind10-changes mailing list