Browse Source

Merge branch 'trac3706' Tidy up some issues find by cpp check

Shawn Routhier 10 years ago
parent
commit
14a6ed7d6b

+ 4 - 1
src/lib/dhcp/pkt6.cc

@@ -313,7 +313,10 @@ Pkt6::unpackMsg(OptionBuffer::const_iterator begin,
         ((*begin++) << 8) + (*begin++);
     transid_ = transid_ & 0xffffff;
 
-    size -= sizeof(uint32_t); // We just parsed 4 bytes header
+    // See below about invoking Postel's law, as we aren't using
+    // size we don't need to update it.  If we do so in the future
+    // perhaps for stats gathering we can uncomment this.
+    //    size -= sizeof(uint32_t); // We just parsed 4 bytes header
 
     OptionBuffer opt_buffer(begin, end);
 

+ 2 - 2
src/lib/dhcpsrv/host.cc

@@ -225,8 +225,8 @@ void
 Host::addClientClassInternal(ClientClasses& classes,
                              const std::string& class_name) {
     std::string trimmed = util::str::trim(class_name);
-    if (!class_name.empty()) {
-        classes.insert(ClientClass(class_name));
+    if (!trimmed.empty()) {
+        classes.insert(ClientClass(trimmed));
     }
 }
 

+ 1 - 2
src/lib/dhcpsrv/memfile_lease_mgr.cc

@@ -806,8 +806,7 @@ Memfile_LeaseMgr::lfcSetup() {
 template<typename LeaseFileType>
 void Memfile_LeaseMgr::lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file) {
     bool do_lfc = true;
-    // This string will hold a reason for the failure to rote the lease files.
-    std::string error_string = "(no details)";
+
     // Check if the copy of the lease file exists already. If it does, it
     // is an indication that another LFC instance may be in progress or
     // may be stalled. In that case we don't want to rotate the current

+ 0 - 1
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc

@@ -155,7 +155,6 @@ public:
              ++i) {
             Memfile_LeaseMgr::LFCFileType type = static_cast<
                 Memfile_LeaseMgr::LFCFileType>(i);
-            std::string suffix = Memfile_LeaseMgr::appendSuffix(base_name, type);
             LeaseFileIO io(Memfile_LeaseMgr::appendSuffix(base_name, type));
             io.removeFile();
         }

+ 1 - 2
src/lib/log/logger_unittest_support.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2011,2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011,2014,2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -80,7 +80,6 @@ void initLogger(isc::log::Severity severity, int dbglevel) {
 
     // Root logger name is defined by the environment variable KEA_LOGGER_ROOT.
     // If not present, the name is "kea".
-    const char* DEFAULT_ROOT = "kea";
     const char* root = getenv("KEA_LOGGER_ROOT");
     if (! root) {
         // If not present, the name is "kea".

+ 8 - 1
src/lib/util/process_spawn.cc

@@ -30,7 +30,14 @@ namespace util {
 /// avoid exposing the internals of the implementation, such as
 /// custom handling of a SIGCHLD signal, and the conversion of the
 /// arguments of the executable from the STL container to the array.
-class ProcessSpawnImpl {
+///
+/// This class is made noncopyable so that we don't have attempts
+/// to make multiple copies of an object.  This avoid problems
+/// with multiple copies of objects for a single global resource
+/// such as the SIGCHLD signal handler. In addition making it
+/// noncopyable keeps the static check code from flagging the
+/// lack of a copy constructor as an issue.
+class ProcessSpawnImpl : boost::noncopyable {
 public:
 
     /// @brief Constructor.

+ 10 - 1
src/lib/util/process_spawn.h

@@ -16,6 +16,7 @@
 #define PROCESS_SPAWN_H
 
 #include <exceptions/exceptions.h>
+#include <boost/noncopyable.hpp>
 #include <string>
 #include <sys/types.h>
 #include <vector>
@@ -53,10 +54,18 @@ typedef std::vector<std::string> ProcessArgs;
 /// attempt to register a new SIGCHLD signal handler and, as a
 /// consequence, the new @c ProcessSpawn object will fail to create.
 ///
+/// This class is made noncopyable so that we don't have attempts
+/// to make multiple copies of an object.  This avoid problems
+/// with multiple copies of objects for a single global resource
+/// such as the SIGCHLD signal handler. In addition making it
+/// noncopyable keeps the static check code from flagging the
+/// lack of a copy constructor as an issue.
+///
 /// @todo The SIGCHLD handling logic should be moved to the @c SignalSet
 /// class so as multiple instances of the @c ProcessSpawn use the same
 /// SIGCHLD signal handler.
-class ProcessSpawn {
+
+class ProcessSpawn : boost::noncopyable {
 public:
 
     /// @brief Constructor.

+ 2 - 2
tests/tools/dhcp-ubench/memfile_ubench.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -247,7 +247,7 @@ void memfile_uBenchmark::createLease4Test() {
         lease->cltt = cltt;
         lease->pool_id = pool_id;
         lease->fixed = fixed;
-        lease->hostname = "foo";
+        lease->hostname = hostname;
         lease->fqdn_fwd = fqdn_fwd;
         lease->fqdn_rev = fqdn_rev;