Commit 98bcbd53 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[2987] Changes as a result of the review.

parent 77def77e
...@@ -40,16 +40,13 @@ public: ...@@ -40,16 +40,13 @@ public:
/// @brief Constructor /// @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 /// Explcit initialization is performed here because some of the
/// tests do not initialize this value. In such cases, destructor /// tests do not initialize this value. In such cases, destructor
/// could invoke close() on uninitialized socket descriptor which /// could invoke close() on uninitialized socket descriptor which
/// would result in errors being reported by Valgrind. Note that /// would result in errors being reported by Valgrind.
/// 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.
PktFilterInetTest() PktFilterInetTest()
: socket_(0) { : socket_(-1) {
// Initialize ifname_ and ifindex_. // Initialize ifname_ and ifindex_.
loInit(); loInit();
} }
...@@ -60,7 +57,9 @@ public: ...@@ -60,7 +57,9 @@ public:
~PktFilterInetTest() { ~PktFilterInetTest() {
// Cleanup after each test. This guarantees // Cleanup after each test. This guarantees
// that the socket does not hang after a test. // that the socket does not hang after a test.
close(socket_); if (socket_ >= 0) {
close(socket_);
}
} }
/// @brief Detect loopback interface. /// @brief Detect loopback interface.
......
...@@ -44,16 +44,13 @@ public: ...@@ -44,16 +44,13 @@ public:
/// @brief Constructor /// @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 /// Explcit initialization is performed here because some of the
/// tests do not initialize this value. In such cases, destructor /// tests do not initialize this value. In such cases, destructor
/// could invoke close() on uninitialized socket descriptor which /// could invoke close() on uninitialized socket descriptor which
/// would result in errors being reported by Valgrind. Note that /// would result in errors being reported by Valgrind.
/// 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.
PktFilterLPFTest() PktFilterLPFTest()
: socket_(0) { : socket_(-1) {
// Initialize ifname_ and ifindex_. // Initialize ifname_ and ifindex_.
loInit(); loInit();
} }
...@@ -64,7 +61,9 @@ public: ...@@ -64,7 +61,9 @@ public:
~PktFilterLPFTest() { ~PktFilterLPFTest() {
// Cleanup after each test. This guarantees // Cleanup after each test. This guarantees
// that the socket does not hang after a test. // that the socket does not hang after a test.
close(socket_); if (socket_ >= 0) {
close(socket_);
}
} }
/// @brief Detect loopback interface. /// @brief Detect loopback interface.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment