This is an automated email from the ASF dual-hosted git repository.

bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 9665276  Prevented closing invalid file descriptors.
9665276 is described below

commit 96652761580851b7a84be0cf8f9f026279c91599
Author: Benjamin Bannier <[email protected]>
AuthorDate: Wed Feb 27 14:11:58 2019 +0100

    Prevented closing invalid file descriptors.
    
    During the refactoring of `d838f2958e` we reorganized the code flow to
    propagate failures from `os::close` and introduce code which migh
    close an invalid file descriptor. While this would produce an `Error`
    result from `mktemp` in any case, it would have lead to confusing
    error messages in that scenario. This patch prevents closing invalid
    file descriptors altogether which is consistent with the
    pre-refactoring behavior.
    
    Review: https://reviews.apache.org/r/70046/
---
 3rdparty/stout/include/stout/os/posix/mktemp.hpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/3rdparty/stout/include/stout/os/posix/mktemp.hpp 
b/3rdparty/stout/include/stout/os/posix/mktemp.hpp
index 8dab259..14fa9d2 100644
--- a/3rdparty/stout/include/stout/os/posix/mktemp.hpp
+++ b/3rdparty/stout/include/stout/os/posix/mktemp.hpp
@@ -40,17 +40,17 @@ inline Try<std::string> mktemp(
   ::memcpy(_path, path.c_str(), path.size() + 1);
 
   int_fd fd = ::mkstemp(_path);
-  Try<std::string> temp = std::string(_path);
+  std::string temp(_path);
   delete[] _path;
 
   if (fd < 0) {
-    temp = ErrnoError();
+    return ErrnoError();
   }
 
   Try<Nothing> close = os::close(fd);
 
   // We propagate `close` failures if creation of the temp file was successful.
-  if (temp.isSome() && close.isError()) {
+  if (close.isError()) {
     return Error("Failed to close '" + stringify(fd) + "':" + close.error());
   }
 

Reply via email to