From: Francis Dupont Date: Thu, 1 Oct 2015 15:55:53 +0000 (+0200) Subject: [4062] Moved to Stephen's style for restore X-Git-Tag: trac3874_base~34^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5bda4c48a42113fdbdb053398c036ecfbdff8929;p=thirdparty%2Fkea.git [4062] Moved to Stephen's style for restore --- diff --git a/src/lib/dhcpsrv/tests/daemon_unittest.cc b/src/lib/dhcpsrv/tests/daemon_unittest.cc index d0945dfab0..bcc7d09a8d 100644 --- a/src/lib/dhcpsrv/tests/daemon_unittest.cc +++ b/src/lib/dhcpsrv/tests/daemon_unittest.cc @@ -59,7 +59,7 @@ public: /// @brief Constructor DaemonTest() : env_(0), env_copy_() { // Take a copy of KEA_PIDFILE_DIR environment variable value - env_ = getenv("KEA_PIDFILE_DIR"); + char *env_ = getenv("KEA_PIDFILE_DIR"); if (env_) { env_copy_ = std::string(env_); } @@ -73,16 +73,14 @@ public: ~DaemonTest() { isc::log::setDefaultLoggingOutput(); // Restore KEA_PIDFILE_DIR environment variable value - env_ = getenv("KEA_PIDFILE_DIR"); - if (!env_copy_.empty() && (!env_ || !env_copy_.compare(env_))) { - setenv("KEA_PIDFILE_DIR", env_copy_.c_str(), 1); + if (env_copy_.empty()) { + static_cast(unsetenv("KEA_PIDFILE_DIR")); + } else { + static_cast(setenv("KEA_PIDFILE_DIR", env_copy_.c_str(), 1)); } } private: - /// @brief KEA_PIDFILE_DIR environment variable value - char* env_; - /// @brief copy of KEA_PIDFILE_DIR environment variable value std::string env_copy_; };