BIND 10 trac781, updated. dcf58b7836e854107438368905576de7d29e0e3b [trac781] some trivial changes: - editorial/style fixes - constify things in trivial cases - catch exceptions by const reference

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Apr 18 22:14:25 UTC 2011


The branch, trac781 has been updated
       via  dcf58b7836e854107438368905576de7d29e0e3b (commit)
      from  f4f11a9b1c09adb07e2d6b99a0bd342d5a75ea3f (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 dcf58b7836e854107438368905576de7d29e0e3b
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Apr 18 15:14:13 2011 -0700

    [trac781] some trivial changes:
    - editorial/style fixes
    - constify things in trivial cases
    - catch exceptions by const reference

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

Summary of changes:
 src/lib/crypto/crypto.cc                 |   12 ++++++------
 src/lib/crypto/crypto.h                  |    2 +-
 src/lib/crypto/tests/crypto_unittests.cc |   20 +++++++++++---------
 src/lib/crypto/tests/run_unittests.cc    |    2 +-
 src/lib/dns/tsigkey.cc                   |   12 ++++++------
 5 files changed, 25 insertions(+), 23 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/crypto/crypto.cc b/src/lib/crypto/crypto.cc
index 8aba543..5319831 100644
--- a/src/lib/crypto/crypto.cc
+++ b/src/lib/crypto/crypto.cc
@@ -60,7 +60,7 @@ class CryptoImpl {
 public:
     CryptoImpl() {}
     ~CryptoImpl() {};
-        
+
 private:
     Botan::LibraryInitializer _botan_init;
 };
@@ -68,7 +68,7 @@ private:
 Crypto::Crypto() {
     try {
         impl_ = new CryptoImpl();
-    } catch (Botan::Exception ex) {
+    } catch (const Botan::Exception& ex) {
         isc_throw(InitializationError, ex.what());
     }
 }
@@ -86,7 +86,7 @@ public:
         try {
             hash = Botan::get_hash(
                 getBotanHashAlgorithmName(hash_algorithm));
-        } catch (const Botan::Algorithm_Not_Found) {
+        } catch (const Botan::Algorithm_Not_Found&) {
             isc_throw(isc::crypto::UnsupportedAlgorithm,
                       "Unknown hash algorithm: " + hash_algorithm);
         }
@@ -113,7 +113,7 @@ public:
 
     ~HMACImpl() { delete hmac_; }
 
-    size_t getOutputLength() {
+    size_t getOutputLength() const {
         return (hmac_->OUTPUT_LENGTH);
     }
 
@@ -177,8 +177,8 @@ HMAC::~HMAC() {
 }
 
 size_t
-HMAC::getOutputLength() {
-    return impl_->getOutputLength();
+HMAC::getOutputLength() const {
+    return (impl_->getOutputLength());
 }
 
 void
diff --git a/src/lib/crypto/crypto.h b/src/lib/crypto/crypto.h
index bde4908..b5d4b2c 100644
--- a/src/lib/crypto/crypto.h
+++ b/src/lib/crypto/crypto.h
@@ -114,7 +114,7 @@ public:
     /// \brief Returns the output size of the digest
     ///
     /// \return output size of the digest
-    size_t getOutputLength();
+    size_t getOutputLength() const;
 
     /// \brief Add data to digest
     ///
diff --git a/src/lib/crypto/tests/crypto_unittests.cc b/src/lib/crypto/tests/crypto_unittests.cc
index 2c6c7a3..f81c02b 100644
--- a/src/lib/crypto/tests/crypto_unittests.cc
+++ b/src/lib/crypto/tests/crypto_unittests.cc
@@ -28,8 +28,10 @@ namespace {
             ASSERT_EQ(data1[i], data2[i]);
         }
     }
-    
-    void checkBuffer(const OutputBuffer& buf, uint8_t *data, size_t len) {
+
+    void checkBuffer(const OutputBuffer& buf, const uint8_t* data,
+                     size_t len)
+    {
         ASSERT_EQ(len, buf.getLength());
         checkData(static_cast<const uint8_t*>(buf.getData()), data, len);
     }
@@ -39,7 +41,7 @@ namespace {
                         const void* secret,
                         size_t secret_len,
                         const HMAC::HashAlgorithm hash_algorithm,
-                        uint8_t* expected_hmac,
+                        const uint8_t* expected_hmac,
                         size_t hmac_len) {
         OutputBuffer data_buf(data.size());
         data_buf.writeData(data.c_str(), data.size());
@@ -72,7 +74,7 @@ namespace {
                           const void* secret,
                           size_t secret_len,
                           const HMAC::HashAlgorithm hash_algorithm,
-                          uint8_t* expected_hmac,
+                          const uint8_t* expected_hmac,
                           size_t hmac_len) {
         OutputBuffer data_buf(data.size());
         data_buf.writeData(data.c_str(), data.size());
@@ -103,7 +105,7 @@ namespace {
                           const void* secret,
                           size_t secret_len,
                           const HMAC::HashAlgorithm hash_algorithm,
-                          uint8_t* expected_hmac,
+                          const uint8_t* expected_hmac,
                           size_t hmac_len) {
         HMAC hmac_sign(secret, secret_len, hash_algorithm);
         hmac_sign.update(data.c_str(), data.size());
@@ -123,11 +125,11 @@ namespace {
                          const void* secret,
                          size_t secret_len,
                          const HMAC::HashAlgorithm hash_algorithm,
-                         uint8_t* expected_hmac,
+                         const uint8_t* expected_hmac,
                          size_t hmac_len) {
         HMAC hmac_sign(secret, secret_len, hash_algorithm);
         hmac_sign.update(data.c_str(), data.size());
-        
+
         uint8_t sig[hmac_len];
 
         hmac_sign.sign(sig, hmac_len);
@@ -145,7 +147,7 @@ namespace {
                     const void* secret,
                     size_t secret_len,
                     const HMAC::HashAlgorithm hash_algorithm,
-                    uint8_t* expected_hmac,
+                    const uint8_t* expected_hmac,
                     size_t hmac_len) {
         doHMACTestConv(data, secret, secret_len, hash_algorithm,
                        expected_hmac, hmac_len);
@@ -169,7 +171,7 @@ TEST(CryptoTest, HMAC_MD5_RFC2202_SIGN) {
                                 0xbb, 0x1c, 0x13, 0xf4, 0x8e, 0xf8,
                                 0x15, 0x8b, 0xfc, 0x9d };
     doHMACTest("Hi There", secret, 16, HMAC::MD5, hmac_expected, 16);
-    
+
     uint8_t hmac_expected2[] = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0,
                                  0xb5, 0x03, 0xea, 0xa8, 0x6e, 0x31,
                                  0x0a, 0x5d, 0xb7, 0x38 };
diff --git a/src/lib/crypto/tests/run_unittests.cc b/src/lib/crypto/tests/run_unittests.cc
index 1ef3ff3..b8f0508 100644
--- a/src/lib/crypto/tests/run_unittests.cc
+++ b/src/lib/crypto/tests/run_unittests.cc
@@ -21,6 +21,6 @@ int
 main(int argc, char* argv[]) {
     ::testing::InitGoogleTest(&argc, argv);
     isc::crypto::Crypto crypto;
-    
+
     return (RUN_ALL_TESTS());
 }
diff --git a/src/lib/dns/tsigkey.cc b/src/lib/dns/tsigkey.cc
index 85bc22c..4edeca9 100644
--- a/src/lib/dns/tsigkey.cc
+++ b/src/lib/dns/tsigkey.cc
@@ -63,27 +63,27 @@ TSIGKey::TSIGKey(const Name& key_name, const Name& algorithm_name,
 }
 
 TSIGKey::TSIGKey(const std::string& str) : impl_(NULL) {
-    size_t pos = str.find(':');
-    if (pos == 0 || pos == str.npos || pos == str.size()-1) {
+    const size_t pos = str.find(':');
+    if (pos == 0 || pos == str.npos || pos == str.size() - 1) {
         // error
         isc_throw(InvalidParameter, "Invalid TSIG key string");
     }
     try {
-        Name key_name(str.substr(0, pos));
+        const Name key_name(str.substr(0, pos));
         Name algo_name("hmac-md5.sig-alg.reg.int");
 
         // optional algorithm part
-        size_t pos2 = str.find(':', pos+1);
+        size_t pos2 = str.find(':', pos + 1);
         if (pos2 != str.npos) {
             if (pos2 == pos + 1) {
                 isc_throw(InvalidParameter, "Invalid TSIG key string");
             }
-            algo_name = Name(str.substr(pos2+1));
+            algo_name = Name(str.substr(pos2 + 1));
         } else {
             pos2 = str.size() - pos;
         }
 
-        std::string secret_str = str.substr(pos + 1, pos2 - pos - 1);
+        const std::string secret_str = str.substr(pos + 1, pos2 - pos - 1);
 
         if (algo_name != HMACMD5_NAME() &&
             algo_name != HMACSHA1_NAME() &&




More information about the bind10-changes mailing list