BIND 10 trac2546, updated. a69ebe7341bfbbc01037e71e66b0c6e7121ca6cd [2546] Address some cppcheck issues

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Dec 12 13:44:28 UTC 2012


The branch, trac2546 has been updated
       via  a69ebe7341bfbbc01037e71e66b0c6e7121ca6cd (commit)
      from  4f17a81c04b1364a0835e9a9b9c26adc6c159cd3 (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 a69ebe7341bfbbc01037e71e66b0c6e7121ca6cd
Author: Stephen Morris <stephen at isc.org>
Date:   Wed Dec 12 13:44:07 2012 +0000

    [2546] Address some cppcheck issues

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

Summary of changes:
 src/lib/dhcp/pkt4.cc                              |   15 ++++++++-------
 src/lib/dhcpsrv/alloc_engine.cc                   |    2 +-
 src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc |    2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/pkt4.cc b/src/lib/dhcp/pkt4.cc
index a232d02..63ab513 100644
--- a/src/lib/dhcp/pkt4.cc
+++ b/src/lib/dhcp/pkt4.cc
@@ -18,6 +18,7 @@
 #include <dhcp/pkt4.h>
 #include <exceptions/exceptions.h>
 
+#include <algorithm>
 #include <iostream>
 #include <sstream>
 
@@ -224,7 +225,7 @@ Pkt4::setHWAddr(uint8_t hType, uint8_t hlen,
                 const std::vector<uint8_t>& macAddr) {
     /// TODO Rewrite this once support for client-identifier option
     /// is implemented (ticket 1228?)
-    if (hlen>MAX_CHADDR_LEN) {
+    if (hlen > MAX_CHADDR_LEN) {
         isc_throw(OutOfRange, "Hardware address (len=" << hlen
                   << " too long. Max " << MAX_CHADDR_LEN << " supported.");
     }
@@ -234,8 +235,8 @@ Pkt4::setHWAddr(uint8_t hType, uint8_t hlen,
 
     htype_ = hType;
     hlen_ = hlen;
-    memset(chaddr_, 0, MAX_CHADDR_LEN);
-    memcpy(chaddr_, &macAddr[0], hlen);
+    std::copy(&macAddr[0], &macAddr[hlen], &chaddr_[0]);
+    std::fill(&chaddr_[hlen], &chaddr_[MAX_CHADDR_LEN], 0);
 }
 
 void
@@ -244,8 +245,8 @@ Pkt4::setSname(const uint8_t* sname, size_t snameLen /*= MAX_SNAME_LEN*/) {
         isc_throw(OutOfRange, "sname field (len=" << snameLen
                   << ") too long, Max " << MAX_SNAME_LEN << " supported.");
     }
-    memset(sname_, 0, MAX_SNAME_LEN);
-    memcpy(sname_, sname, snameLen);
+    std::copy(&sname[0], &sname[snameLen], &sname_[0]);
+    std::fill(&sname_[snameLen], &sname_[MAX_SNAME_LEN], 0);
 
     // no need to store snameLen as any empty space is filled with 0s
 }
@@ -256,8 +257,8 @@ Pkt4::setFile(const uint8_t* file, size_t fileLen /*= MAX_FILE_LEN*/) {
         isc_throw(OutOfRange, "file field (len=" << fileLen
                   << ") too long, Max " << MAX_FILE_LEN << " supported.");
     }
-    memset(file_, 0, MAX_FILE_LEN);
-    memcpy(file_, file, fileLen);
+    std::copy(&file[0], &file[fileLen], &file_[0]);
+    std::fill(&file_[fileLen], &file_[MAX_FILE_LEN], 0);
 
     // no need to store fileLen as any empty space is filled with 0s
 }
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index 3a53887..77a2df4 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -67,7 +67,7 @@ AllocEngine::IterativeAllocator::pickAddress(const Subnet6Ptr& subnet,
 
     const Pool6Collection& pools = subnet->getPools();
 
-    if (pools.size() == 0) {
+    if (pools.empty()) {
         isc_throw(AllocFailed, "No pools defined in selected subnet");
     }
 
diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
index 7d6f4d1..746ef00 100644
--- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
@@ -469,7 +469,7 @@ public:
     ///
     /// @param leases Vector of pointers to leases
     template <typename T>
-    void checkLeasesDifferent(const std::vector<T> leases) const {
+    void checkLeasesDifferent(const std::vector<T>& leases) const {
 
         // Check they were created
         for (int i = 0; i < leases.size(); ++i) {



More information about the bind10-changes mailing list