]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2987] Changes as a result of the review.
authorMarcin Siodelski <marcin@isc.org>
Tue, 4 Jun 2013 15:34:16 +0000 (17:34 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 4 Jun 2013 15:34:16 +0000 (17:34 +0200)
src/lib/dhcp/tests/pkt_filter_inet_unittest.cc
src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc

index 5607103ce4cba8debe4f754acf8fb7d106595225..eaf2e62ef2055c9ece9a4028b23f7b72ed4e0ce3 100644 (file)
@@ -40,16 +40,13 @@ public:
 
     /// @brief Constructor
     ///
-    /// This constructor initializes socket_ member to the value of 0.
+    /// This constructor initializes socket_ member to a negative value.
     /// Explcit initialization is performed here because some of the
     /// tests do not initialize this value. In such cases, destructor
     /// could invoke close() on uninitialized socket descriptor which
-    /// would result in errors being reported by Valgrind. Note that
-    /// by initializing the class member to a valid socket descriptor
-    /// value (non-negative) we avoid Valgrind warning about trying to
-    /// close the invalid socket descriptor.
+    /// would result in errors being reported by Valgrind.
     PktFilterInetTest()
-        : socket_(0) {
+        : socket_(-1) {
         // Initialize ifname_ and ifindex_.
         loInit();
     }
@@ -60,7 +57,9 @@ public:
     ~PktFilterInetTest() {
         // Cleanup after each test. This guarantees
         // that the socket does not hang after a test.
-        close(socket_);
+        if (socket_ >= 0) {
+            close(socket_);
+        }
     }
 
     /// @brief Detect loopback interface.
index 4587bd54ced769b8f710010f85901ad5953a5ea0..742a7c98c380b9f56523c33e57955333e8239a5e 100644 (file)
@@ -44,16 +44,13 @@ public:
 
     /// @brief Constructor
     ///
-    /// This constructor initializes socket_ member to the value of 0.
+    /// This constructor initializes socket_ member to a negative value.
     /// Explcit initialization is performed here because some of the
     /// tests do not initialize this value. In such cases, destructor
     /// could invoke close() on uninitialized socket descriptor which
-    /// would result in errors being reported by Valgrind. Note that
-    /// by initializing the class member to a valid socket descriptor
-    /// value (non-negative) we avoid Valgrind warning about trying to
-    /// close the invalid socket descriptor.
+    /// would result in errors being reported by Valgrind.
     PktFilterLPFTest()
-        : socket_(0) {
+        : socket_(-1) {
         // Initialize ifname_ and ifindex_.
         loInit();
     }
@@ -64,7 +61,9 @@ public:
     ~PktFilterLPFTest() {
         // Cleanup after each test. This guarantees
         // that the socket does not hang after a test.
-        close(socket_);
+        if (socket_ >= 0) {
+            close(socket_);
+        }
     }
 
     /// @brief Detect loopback interface.