diff options
author | Yi Jin <jinyithu@google.com> | 2018-04-25 16:51:40 -0700 |
---|---|---|
committer | Yi Jin <jinyithu@google.com> | 2018-04-25 16:51:40 -0700 |
commit | c5b71ee2abd1c418de9bc2a465eac02362d75ba2 (patch) | |
tree | a7ac4d90df4eec5f3df1e4b231e27f663d6d01b4 /libs/protoutil/src | |
parent | 63b534768e710ae7a0649f9a92d2402ec9ebdf38 (diff) |
Use function from libbase instead.
Bug: 77342154
Test: atest libprotoutil_test && atest incidentd_test with
libprotoutil.so pushed to device
Change-Id: I38d200f2495b00f632722ddddf9ccab76c147cc4
Diffstat (limited to 'libs/protoutil/src')
-rw-r--r-- | libs/protoutil/src/ProtoOutputStream.cpp | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/libs/protoutil/src/ProtoOutputStream.cpp b/libs/protoutil/src/ProtoOutputStream.cpp index 22b9709ef066..3fee7e42338d 100644 --- a/libs/protoutil/src/ProtoOutputStream.cpp +++ b/libs/protoutil/src/ProtoOutputStream.cpp @@ -17,6 +17,7 @@ #include <inttypes.h> +#include <android-base/file.h> #include <android/util/protobuf.h> #include <android/util/ProtoOutputStream.h> #include <cutils/log.h> @@ -467,19 +468,6 @@ ProtoOutputStream::size() return mBuffer.size(); } -static bool write_all(int fd, uint8_t const* buf, size_t size) -{ - while (size > 0) { - ssize_t amt = ::write(fd, buf, size); - if (amt < 0) { - return false; - } - size -= amt; - buf += amt; - } - return true; -} - bool ProtoOutputStream::flush(int fd) { @@ -488,7 +476,7 @@ ProtoOutputStream::flush(int fd) EncodedBuffer::iterator it = mBuffer.begin(); while (it.readBuffer() != NULL) { - if (!write_all(fd, it.readBuffer(), it.currentToRead())) return false; + if (!android::base::WriteFully(fd, it.readBuffer(), it.currentToRead())) return false; it.rp()->move(it.currentToRead()); } return true; |