summaryrefslogtreecommitdiffstats
path: root/runtime/base/unix_file/fd_file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/base/unix_file/fd_file.cc')
-rw-r--r--runtime/base/unix_file/fd_file.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/base/unix_file/fd_file.cc b/runtime/base/unix_file/fd_file.cc
index f48c76db23..87d1c0655d 100644
--- a/runtime/base/unix_file/fd_file.cc
+++ b/runtime/base/unix_file/fd_file.cc
@@ -102,11 +102,11 @@ bool FdFile::IsOpened() const {
return fd_ >= 0;
}
-bool FdFile::ReadFully(void* buffer, int64_t byte_count) {
+bool FdFile::ReadFully(void* buffer, size_t byte_count) {
char* ptr = static_cast<char*>(buffer);
while (byte_count > 0) {
- int bytes_read = TEMP_FAILURE_RETRY(read(fd_, ptr, byte_count));
- if (bytes_read <= 0) {
+ ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd_, ptr, byte_count));
+ if (bytes_read == -1) {
return false;
}
byte_count -= bytes_read; // Reduce the number of remaining bytes.
@@ -115,15 +115,15 @@ bool FdFile::ReadFully(void* buffer, int64_t byte_count) {
return true;
}
-bool FdFile::WriteFully(const void* buffer, int64_t byte_count) {
+bool FdFile::WriteFully(const void* buffer, size_t byte_count) {
const char* ptr = static_cast<const char*>(buffer);
while (byte_count > 0) {
- int bytes_read = TEMP_FAILURE_RETRY(write(fd_, ptr, byte_count));
- if (bytes_read < 0) {
+ ssize_t bytes_written = TEMP_FAILURE_RETRY(write(fd_, ptr, byte_count));
+ if (bytes_written == -1) {
return false;
}
- byte_count -= bytes_read; // Reduce the number of remaining bytes.
- ptr += bytes_read; // Move the buffer forward.
+ byte_count -= bytes_written; // Reduce the number of remaining bytes.
+ ptr += bytes_written; // Move the buffer forward.
}
return true;
}