From 75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e Mon Sep 17 00:00:00 2001 From: chirantan Date: Tue, 7 Oct 2014 16:15:30 -0700 Subject: Refactor AppendToFile and WriteFileDescriptor - Unify the behavior of the windows and posix implementations of these functions. - Simplify the interface by having them just indicate success or failure instead of making callers deal with partial writes. BUG=418837 Signed-off-by: Chirantan Ekbote Review URL: https://codereview.chromium.org/614893004 Cr-Commit-Position: refs/heads/master@{#298604} --- components/metrics/serialization/serialization_utils.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'components/metrics') diff --git a/components/metrics/serialization/serialization_utils.cc b/components/metrics/serialization/serialization_utils.cc index 0eca24b..30c2675 100644 --- a/components/metrics/serialization/serialization_utils.cc +++ b/components/metrics/serialization/serialization_utils.cc @@ -196,17 +196,16 @@ bool SerializationUtils::WriteMetricToFile(const MetricSample& sample, // The file containing the metrics samples will only be read by programs on // the same device so we do not check endianness. - if (base::WriteFileDescriptor(file_descriptor.get(), - reinterpret_cast(&size), - sizeof(size)) != sizeof(size)) { - DLOG(ERROR) << "error writing message length " << errno; + if (!base::WriteFileDescriptor(file_descriptor.get(), + reinterpret_cast(&size), + sizeof(size))) { + DPLOG(ERROR) << "error writing message length"; return false; } - if (base::WriteFileDescriptor( - file_descriptor.get(), msg.c_str(), msg.length()) != - static_cast(msg.length())) { - DLOG(ERROR) << "error writing message" << errno; + if (!base::WriteFileDescriptor( + file_descriptor.get(), msg.c_str(), msg.size())) { + DPLOG(ERROR) << "error writing message"; return false; } -- cgit v1.1