Repository: mesos Updated Branches: refs/heads/master de9c8dc9a -> 1ab9618ef
Removed unnecessary close calls on ifstream and ofstream. std::ifstream and std::ofstream have RAII semantics and will close() upon destruction. Review: https://reviews.apache.org/r/38775 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/445fe283 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/445fe283 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/445fe283 Branch: refs/heads/master Commit: 445fe28361a79e20d2b53f02667d571a80a48ebb Parents: de9c8dc Author: Benjamin Mahler <[email protected]> Authored: Fri Sep 25 14:48:49 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Fri Sep 25 14:52:38 2015 -0700 ---------------------------------------------------------------------- .../libprocess/3rdparty/stout/include/stout/os/posix/read.hpp | 7 ++++--- 3rdparty/libprocess/3rdparty/stout/include/stout/proc.hpp | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/445fe283/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/read.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/read.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/read.hpp index e154bb6..ffacce1 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/read.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/read.hpp @@ -74,11 +74,12 @@ inline Result<std::string> read(int fd, size_t size) #ifdef __sun // getline is not available on Solaris, using STL. inline Try<std::string> read(const std::string& path) { - std::ifstream ifs(path.c_str()); - if (!ifs.is_open()) { + std::ifstream file(path.c_str()); + if (!file.is_open()) { + // Does ifstream actually set errno? return ErrnoError("Failed to open file '" + path + "'"); } - return std::string((std::istreambuf_iterator<char>(ifs)), + return std::string((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>())); } #else http://git-wip-us.apache.org/repos/asf/mesos/blob/445fe283/3rdparty/libprocess/3rdparty/stout/include/stout/proc.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/proc.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/proc.hpp index 66ece4d..200b8fc 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/proc.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/proc.hpp @@ -280,7 +280,6 @@ inline Result<std::string> cmdline(const Option<pid_t>& pid = None()) // Check for any read errors. if (file.fail() && !file.eof()) { - file.close(); return Error("Failed to read '" + path + "'"); } else if (!file.eof()) { file.get(); // Read the null byte. @@ -381,12 +380,9 @@ inline Try<SystemStatus> status() } if (file.fail() && !file.eof()) { - file.close(); return Error("Failed to read /proc/stat"); } - file.close(); - return SystemStatus(btime); } @@ -507,12 +503,9 @@ inline Try<std::list<CPU> > cpus() } if (file.fail() && !file.eof()) { - file.close(); return Error("Failed to read /proc/cpuinfo"); } - file.close(); - return results; }
