]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1845] initialize all members in constructors
authorRazvan Becheriu <razvan@isc.org>
Wed, 9 Jun 2021 09:57:37 +0000 (12:57 +0300)
committerRazvan Becheriu <razvan@isc.org>
Thu, 10 Jun 2021 08:38:05 +0000 (11:38 +0300)
24 files changed:
src/bin/netconf/netconf.h
src/bin/netconf/tests/control_socket_unittests.cc
src/bin/perfdhcp/stats_mgr.h
src/hooks/dhcp/high_availability/tests/ha_config_unittest.cc
src/lib/dhcpsrv/pgsql_host_data_source.h
src/lib/dhcpsrv/tests/cfg_multi_threading_unittest.cc
src/lib/dhcpsrv/tests/d2_client_unittest.cc
src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc
src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc
src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc
src/lib/dhcpsrv/tests/ncr_generator_unittest.cc
src/lib/dhcpsrv/tests/timer_mgr_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.h
src/lib/dhcpsrv/testutils/memory_host_data_source.h
src/lib/eval/tests/dependency_unittest.cc
src/lib/process/tests/logging_info_unittests.cc
src/lib/util/buffer.h
src/lib/util/io/socketsession.cc
src/lib/util/tests/fd_tests.cc
src/lib/util/tests/pid_file_unittest.cc
src/lib/util/tests/stopwatch_unittest.cc

index 125c5a7b1ac99548868515db8199769bbb11589d..1881ea920896ce73b13b80f817718b1fce0d2382 100644 (file)
@@ -116,9 +116,6 @@ public:
     static void logChanges(S_Session sess, const std::string& model);
 #endif
 
-    /// @brief Cancel flag.
-    bool cancel_;
-
 protected:
     /// @brief Get and display Kea server configuration.
     ///
index 9e7700a1115b66b83678b303674873b3d28ed6dc..ae7ee02bdac05c290c536e3f218396f21f02ac83 100644 (file)
@@ -504,6 +504,7 @@ public:
 /// @brief Test fixture class for http control sockets.
 class HttpControlSocketTest : public ThreadedTest {
 public:
+    /// @brief Constructor
     HttpControlSocketTest()
         : ThreadedTest(), io_service_() {
     }
@@ -597,12 +598,6 @@ public:
 
     /// @brief Pointer to listener.
     HttpListenerPtr listener_;
-
-    /// @brief Done flag (stopping thread).
-    bool done_;
-
-    /// @brief Finished flag (stopped thread).
-    bool finished_;
 };
 
 /// @brief Create the reflecting listener.
index 0ca1695ad268ae7f8b9979fd894468541f0cff56..1130f244b1a8b3c4c178d017162648bf6d5ea576 100644 (file)
@@ -72,7 +72,8 @@ public:
     /// \param name name of the counter used in log file.
     CustomCounter(const std::string& name) :
         counter_(0),
-        name_(name) { };
+        name_(name) {
+    }
 
     /// \brief Increment operator.
     const CustomCounter& operator++() {
@@ -96,15 +97,19 @@ public:
     ///
     /// Method returns counter value.
     ///
-        /// \return counter value.
-    uint64_t getValue() const { return(counter_); }
+    /// \return counter value.
+    uint64_t getValue() const {
+        return (counter_);
+    }
 
     /// \brief Return counter name.
     ///
     /// Method returns counter name.
     ///
-        /// \return counter name.
-    const std::string& getName() const { return(name_); }
+    /// \return counter name.
+    const std::string& getName() const {
+        return (name_);
+    }
 
 private:
     /// \brief Default constructor.
@@ -112,7 +117,8 @@ private:
     /// Default constructor is private because we don't want client
     /// class to call it because we want client class to specify
     /// counter's name.
-    CustomCounter() { };
+    CustomCounter() : counter_(0) {
+    }
 
     uint64_t counter_;  ///< Counter's value.
     std::string name_;  ///< Counter's name.
index 8c965af248c563e4490b0a544c0ac830981754a1..a1fc75bf432e8b0e603bcb5276419150f9bfe10c 100644 (file)
@@ -80,6 +80,7 @@ public:
             }
             result.replace(where, from.size(), repl);
         }
+        return (result);
     }
 };
 
index 7fb251054a18d21a65ff61704bde0934c8491ce9..4d8ba40983301c483b7e72d79bf2597f8bd2d0e9 100644 (file)
@@ -67,9 +67,10 @@ public:
     /// @throw isc::db::DbOpenError Error opening the database
     /// @throw isc::db::DbOperationError An operation on the open database has
     ///        failed.
-   PgSqlHostDataSource(const db::DatabaseConnection::ParameterMap& parameters);
+    PgSqlHostDataSource(const db::DatabaseConnection::ParameterMap& parameters);
 
     /// @brief Virtual destructor.
+    ///
     /// Frees database resources and closes the database connection through
     /// the destruction of member impl_.
     virtual ~PgSqlHostDataSource();
index 72eff79f226847304b1164ec0fc5bd78ccb1497b..5f9edbfac2665d4e71a8829f44c554cecb23b89a 100644 (file)
@@ -20,6 +20,14 @@ namespace {
 
 /// @brief Test fixture class for @c MultiThreadingConfigParser
 class CfgMultiThreadingTest : public ::testing::Test {
+public:
+
+    /// @brief Constructor
+    CfgMultiThreadingTest() = default;
+
+    /// @brief Destructor
+    virtual ~CfgMultiThreadingTest() = default;
+
 protected:
 
     /// @brief Setup for each test.
index 66c30601193e6122f9c83b68d250bdb056e0e897..f246c152d8b463119cca57e069f87633e8b7168d 100644 (file)
@@ -340,6 +340,13 @@ TEST(D2ClientMgr, ipv6Config) {
 /// @brief Test class for execerising manager functions that are
 /// influenced by DDNS parameters.
 class D2ClientMgrParamsTest : public ::testing::Test {
+public:
+    /// @brief Constructor
+    D2ClientMgrParamsTest() = default;
+
+    /// @brief Destructor
+    virtual ~D2ClientMgrParamsTest() = default;
+
 private:
     /// @brief Prepares the class for a test.
     virtual void SetUp() {
index 5d19ef3ebd5d27789759ebb3a937faaefd845d2f..e10dccd137e6a90b8f1bb6f02b8beb970c810bc9 100644 (file)
@@ -23,8 +23,14 @@ namespace {
 
 /// @brief Test fixture class for @c DHCPQueueControlParser
 class DHCPQueueControlParserTest : public ::testing::Test {
-protected:
+public:
+    /// @brief Constructor
+    DHCPQueueControlParserTest() = default;
+
+    /// @brief Destructor
+    virtual ~DHCPQueueControlParserTest() = default;
 
+protected:
     /// @brief Setup for each test.
     ///
     /// Clears the configuration in the @c CfgMgr.
@@ -34,7 +40,6 @@ protected:
     ///
     /// Clears the configuration in the @c CfgMgr.
     virtual void TearDown();
-
 };
 
 void
index 5f5fa03e1192217535f03927aa16f56a870df1e5..103550fcd520cdc2eca7de0c2da97a1b68ee372a 100644 (file)
@@ -74,6 +74,13 @@ factory0(const DatabaseConnection::ParameterMap&) {
 
 // @brief Test fixture class
 class HostDataSourceFactoryTest : public ::testing::Test {
+public:
+    /// @brief Constructor
+    HostDataSourceFactoryTest() = default;
+
+    /// @brief Destructor
+    virtual ~HostDataSourceFactoryTest() = default;
+
 private:
     // @brief Prepares the class for a test.
     virtual void SetUp() {
index 4a82130fec3795882de06be1bb06803e93eae209..4545902356f4ccd186ca7359bf7eac0122cb5226 100644 (file)
@@ -42,8 +42,14 @@ namespace {
 
 /// @brief Test fixture class for @c HostReservationParser.
 class HostReservationParserTest : public ::testing::Test {
-protected:
+public:
+    /// @brief Constructor
+    HostReservationParserTest() = default;
 
+    /// @brief Destructor
+    virtual ~HostReservationParserTest() = default;
+
+protected:
     /// @brief Setup for each test.
     ///
     /// Clears the configuration in the @c CfgMgr.
index 31c0c796b156a26410408c205fced0d1583174c1..c10adde0bf1ef7edeb5668a8d9fb5b0d1f8e7624 100644 (file)
@@ -32,8 +32,14 @@ namespace {
 
 /// @brief Test fixture class for @c HostReservationsListParser.
 class HostReservationsListParserTest : public ::testing::Test {
-protected:
+public:
+    /// @brief Constructor
+    HostReservationsListParserTest() = default;
 
+    /// @brief Destructor
+    virtual ~HostReservationsListParserTest() = default;
+
+protected:
     /// @brief Setup for each test.
     ///
     /// Clears the configuration in the @c CfgMgr. It also initializes
index 8e49695122dc22e5b35ebd76bca5796b301d99a5..2c0170cf5d4257a9c8eb522d784acffaea68e41f 100644 (file)
@@ -39,7 +39,7 @@ public:
     /// @brief Destructor
     ///
     /// Removes any configuration that may have been added in CfgMgr.
-    ~LeaseFileLoaderTest();
+    virtual ~LeaseFileLoaderTest();
 
     /// @brief Prepends the absolute path to the file specified
     /// as an argument.
index 1f3b994bbd59056a42cb2dca56668ef3811f5172..e24a7064ec9005b96d991a8f4952e1000923bf1a 100644 (file)
@@ -23,6 +23,14 @@ namespace {
 
 /// @brief Test fixture class for @c MultiThreadingConfigParser
 class MultiThreadingConfigParserTest : public ::testing::Test {
+public:
+
+    /// @brief Constructor
+    MultiThreadingConfigParserTest() = default;
+
+    /// @brief Destructor
+    virtual ~MultiThreadingConfigParserTest() = default;
+
 protected:
 
     /// @brief Setup for each test.
index 905df55479b89561a6b10e4750ccc7b30ae4df6b..ca6881c015e3e771525cd59018999ecd93367b49 100644 (file)
@@ -49,6 +49,9 @@ public:
         : d2_mgr_(CfgMgr::instance().getD2ClientMgr()), lease_() {
     }
 
+    /// @brief Destructor
+    virtual ~NCRGeneratorTest() = default;
+
     /// @brief Initializes the lease pointer used by the tests and starts D2.
     ///
     /// This method initializes the pointer to the lease which will be used
index 00583740c796c00fcbbfb33a96a04cded3248305..a46afde1e6d386390ffbc853fe2d1a49169b578a 100644 (file)
@@ -27,7 +27,16 @@ namespace {
 
 /// @brief Test fixture class for @c TimerMgr.
 class TimerMgrTest : public ::testing::Test {
+public:
+
+    /// @brief Constructor
+    TimerMgrTest() = default;
+
+    /// @brief Destructor
+    virtual ~TimerMgrTest() = default;
+
 private:
+
     /// @brief Prepares the class for a test.
     virtual void SetUp();
 
index 8444f9370476c089c27c1980e494c01316059ed4..ddaa38d7f4c81360c7bb1c9a113f5fbe516ab22b 100644 (file)
@@ -682,6 +682,14 @@ public:
 
 /// @brief Test fixture class for @c HostMgr class.
 class HostMgrTest : public ::testing::Test {
+public:
+
+    /// @brief Constructor
+    HostMgrTest() = default;
+
+    /// @brief Destructor
+    virtual ~HostMgrTest() = default;
+
 protected:
 
     /// @brief Prepares the class for a test.
index b2d06f48f2ff7db1ef0f97121641637d6862738c..69e68233e66d0c76390da17506432d1bf87def65 100644 (file)
@@ -24,8 +24,12 @@ namespace test {
 class MemHostDataSource : public virtual BaseHostDataSource {
 public:
 
+    /// @brief Constructor.
+    MemHostDataSource() : next_host_id_(0) {
+    }
+
     /// @brief Destructor.
-    virtual ~MemHostDataSource() { }
+    virtual ~MemHostDataSource() = default;
 
     /// BaseHostDataSource methods.
 
index 1f99bfdc7cb602f26ba71decfb6edbc002de5346..19f9121ffff6b2d59f31381ea026fd6af3a4ddb3 100644 (file)
@@ -29,8 +29,13 @@ namespace {
 /// of the dependency of classification expressions.
 class DependencyTest : public ::testing::Test {
 public:
+    /// @brief Constructor
+    DependencyTest() : result_(true) {
+    }
 
-    /// @brief Reset expression and result.
+    /// @brief Destructor
+    ///
+    /// Reset expression and result.
     ~DependencyTest() {
         e_.reset();
         result_ = false;
index 865d6426b36861cc930a6fcaff2a19db5f736b79..f2b7531d974974187b23802e65df832079f481c4 100644 (file)
@@ -51,6 +51,12 @@ TEST(LoggingDestination, equals) {
 class LoggingInfoTest : public ::testing::Test {
 public:
 
+    /// @brief Constructor
+    LoggingInfoTest() = default;
+
+    /// @brief Destructor
+    virtual ~LoggingInfoTest() = default;
+
     /// @brief Setup the test.
     virtual void SetUp() {
         Daemon::setVerbose(false);
index 128db9998097a5da34ea28641b8484cbad6afa2f..aa59488ad69a53f56e0826875cba66744a419a56 100644 (file)
@@ -337,7 +337,7 @@ public:
     }
 
     /// \brief Destructor
-    ~ OutputBuffer() {
+    ~OutputBuffer() {
         free(buffer_);
     }
     //@}
index 573931a30e3315fb94fb300204fb72cc92017710..6dea2ee9f3a55b0abe8175128068805d70a0cc2c 100644 (file)
@@ -76,7 +76,10 @@ const size_t INITIAL_BUFSIZE = 512;
 const int SOCKSESSION_BUFSIZE = (DEFAULT_HEADER_BUFLEN + MAX_DATASIZE) * 2;
 
 struct SocketSessionForwarder::ForwarderImpl {
-    ForwarderImpl() : fd_(-1), buf_(DEFAULT_HEADER_BUFLEN) {}
+    ForwarderImpl() : sock_un_len_(0), fd_(-1), buf_(DEFAULT_HEADER_BUFLEN) {
+        memset(&sock_un_, 0, sizeof(sock_un_));
+    }
+
     struct sockaddr_un sock_un_;
     socklen_t sock_un_len_;
     int fd_;
index f2ffb98e9778c3bf12f0e173f4e9718ad476e4e9..82606f7993b3f08645e91a47eeb5c1abde4ca432 100644 (file)
@@ -24,19 +24,22 @@ namespace {
 const size_t TEST_DATA_SIZE = 8 * 1024 * 1024;
 
 class FDTest : public ::testing::Test {
-    public:
-        unsigned char *data, *buffer;
-        FDTest() :
-            // We do not care what is inside, we just need it to be the same
-            data(new unsigned char[TEST_DATA_SIZE]),
-            buffer(NULL)
-        {
-            memset(data, 0, TEST_DATA_SIZE);
-        }
-        ~ FDTest() {
-            delete[] data;
-            delete[] buffer;
-        }
+public:
+    unsigned char *data, *buffer;
+
+    /// @brief Constructor
+    FDTest() :
+        // We do not care what is inside, we just need it to be the same
+        data(new unsigned char[TEST_DATA_SIZE]),
+        buffer(NULL) {
+        memset(data, 0, TEST_DATA_SIZE);
+    }
+
+    /// @brief Destructor
+    ~FDTest() {
+        delete[] data;
+        delete[] buffer;
+    }
 };
 
 // Test we read what was sent
index 08b1881eb73a8244bbcf99a6a69a23412990e08b..640a7d8d2634639591df4416d3d9a3027b0d7db3 100644 (file)
@@ -20,6 +20,13 @@ const char* TESTNAME = "pid_file.test";
 
 class PIDFileTest : public ::testing::Test {
 public:
+
+    /// @brief Constructor
+    PIDFileTest() = default;
+
+    /// @brief Destructor
+    virtual ~PIDFileTest() = default;
+
     /// @brief Prepends the absolute path to the file specified
     /// as an argument.
     ///
index ed5649a66eecf770b942a076c53497fe605236ce..28d6c99989e4c4bcafb52960fa472f51a2332478 100644 (file)
@@ -101,6 +101,14 @@ StopwatchMock::getCurrentTime() const {
 
 /// @brief Test fixture class for testing @c StopwatchImpl.
 class StopwatchTest : public ::testing::Test {
+public:
+
+    /// @brief Constructor
+    StopwatchTest() = default;
+
+    /// @brief Destructor
+    virtual ~StopwatchTest() = default;
+
 protected:
 
     /// @brief Set up the test.