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/38776 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7e95a3b5 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7e95a3b5 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7e95a3b5 Branch: refs/heads/master Commit: 7e95a3b5f44d7506dd8fb48cd801b5bda043a57e Parents: 445fe28 Author: Benjamin Mahler <[email protected]> Authored: Fri Sep 25 14:49:05 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Fri Sep 25 14:53:51 2015 -0700 ---------------------------------------------------------------------- src/linux/cgroups.cpp | 15 ++++----------- src/log/tool/benchmark.cpp | 3 --- 2 files changed, 4 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/7e95a3b5/src/linux/cgroups.cpp ---------------------------------------------------------------------- diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp index 6ef42ed..53c568b 100644 --- a/src/linux/cgroups.cpp +++ b/src/linux/cgroups.cpp @@ -127,7 +127,6 @@ static Try<map<string, SubsystemInfo>> subsystems() if (file.fail()) { if (!file.eof()) { - file.close(); return Error("Failed to read /proc/cgroups"); } } else { @@ -149,7 +148,6 @@ static Try<map<string, SubsystemInfo>> subsystems() // Check for any read/parse errors. if (ss.fail() && !ss.eof()) { - file.close(); return Error("Failed to parse /proc/cgroups"); } @@ -158,7 +156,6 @@ static Try<map<string, SubsystemInfo>> subsystems() } } - file.close(); return infos; } @@ -368,12 +365,10 @@ static Try<string> read( ss << file.rdbuf(); if (file.fail()) { - ErrnoError error; // TODO(jieyu): Does ifstream actually set errno? - file.close(); - return error; + // TODO(jieyu): Does ifstream actually set errno? + return ErrnoError(); } - file.close(); return ss.str(); } @@ -404,12 +399,10 @@ static Try<Nothing> write( file << value; if (file.fail()) { - ErrnoError error; // TODO(jieyu): Does ifstream actually set errno? - file.close(); - return error; + // TODO(jieyu): Does ofstream actually set errno? + return ErrnoError(); } - file.close(); return Nothing(); } http://git-wip-us.apache.org/repos/asf/mesos/blob/7e95a3b5/src/log/tool/benchmark.cpp ---------------------------------------------------------------------- diff --git a/src/log/tool/benchmark.cpp b/src/log/tool/benchmark.cpp index 4895dd8..cb823c3 100644 --- a/src/log/tool/benchmark.cpp +++ b/src/log/tool/benchmark.cpp @@ -196,7 +196,6 @@ Try<Nothing> Benchmark::execute(int argc, char** argv) while (getline(input, line)) { Try<Bytes> size = Bytes::parse(strings::trim(line)); if (size.isError()) { - input.close(); return Error("Failed to parse the trace file: " + size.error()); } @@ -256,8 +255,6 @@ Try<Nothing> Benchmark::execute(int argc, char** argv) << " in " << durations[i].ms() << " ms" << endl; } - output.close(); - return Nothing(); }
