Skip to content

Commit

Permalink
Address reviewer feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Sep 29, 2022
1 parent d8f29c8 commit dc27669
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
3 changes: 0 additions & 3 deletions testing/include/gz/common/testing/RedirectConsoleStream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,5 @@ inline RedirectConsoleStream RedirectStderr()
auto path = gz::common::testing::TempPath("stderr.out");
return RedirectConsoleStream(StreamSource::STDERR, path);
}


} // namespace gz::common::testing

#endif // GZ_COMMON_TESTING_REDIRECTCONSOLE_STREAM_HH
35 changes: 17 additions & 18 deletions testing/src/RedirectConsoleStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*
*/

#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>

#include "gz/common/testing/RedirectConsoleStream.hh"
#include "gz/common/Console.hh"
#include <gz/common/testing/RedirectConsoleStream.hh>
#include <gz/common/Console.hh>
#include <gz/common/testing/TestPaths.hh>

#include <fstream>
#include <gz/utils/SuppressWarning.hh>
#include <sstream>

#ifdef _WIN32
#include <io.h>
Expand Down Expand Up @@ -64,18 +63,18 @@ class RedirectConsoleStream::Implementation
//////////////////////////////////////////////////
void RedirectConsoleStream::Implementation::RemoveRedirection()
{
// MSVC treats dup and dup2 as deprecated, preferring _dup and _dup2
// We can safely ignore that here.
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION;
/// Restore the orignal source file descriptor
if (this->originalFd != -1)
{
fflush(nullptr);
dup2(this->originalFd, this->fd);
close(this->originalFd);
this->originalFd = -1;
}
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION;
// MSVC treats dup and dup2 as deprecated, preferring _dup and _dup2
// We can safely ignore that here.
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION;
/// Restore the orignal source file descriptor
if (this->originalFd != -1)
{
fflush(nullptr);
dup2(this->originalFd, this->fd);
close(this->originalFd);
this->originalFd = -1;
}
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION;
}

//////////////////////////////////////////////////
Expand Down

0 comments on commit dc27669

Please sign in to comment.