Index: util/file/fd_io.cc |
diff --git a/util/file/fd_io.cc b/util/file/fd_io.cc |
index 270539c404440609a6d54f76f939f7ecf203ed3e..cc97400ba34ba3e827a71f9c9dc1955ad18e1e8d 100644 |
--- a/util/file/fd_io.cc |
+++ b/util/file/fd_io.cc |
@@ -74,24 +74,42 @@ ssize_t WriteFD(int fd, const void* buffer, size_t size) { |
return ReadOrWrite<WriteTraits>(fd, buffer, size); |
} |
-void CheckedReadFD(int fd, void* buffer, size_t size) { |
+bool LoggingReadFD(int fd, void* buffer, size_t size) { |
ssize_t expect = base::checked_cast<ssize_t>(size); |
ssize_t rv = ReadFD(fd, buffer, size); |
if (rv < 0) { |
- PCHECK(rv == expect) << "read"; |
- } else { |
- CHECK_EQ(rv, expect) << "read"; |
+ PLOG(ERROR) << "read"; |
+ return false; |
} |
+ if (rv != expect) { |
+ LOG(ERROR) << "read: expected " << expect << ", observed " << rv; |
+ return false; |
+ } |
+ |
+ return true; |
} |
-void CheckedWriteFD(int fd, const void* buffer, size_t size) { |
+bool LoggingWriteFD(int fd, const void* buffer, size_t size) { |
ssize_t expect = base::checked_cast<ssize_t>(size); |
ssize_t rv = WriteFD(fd, buffer, size); |
if (rv < 0) { |
- PCHECK(rv == expect) << "write"; |
- } else { |
- CHECK_EQ(rv, expect) << "write"; |
+ PLOG(ERROR) << "write"; |
+ return false; |
} |
+ if (rv != expect) { |
+ LOG(ERROR) << "write: expected " << expect << ", observed " << rv; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+void CheckedReadFD(int fd, void* buffer, size_t size) { |
+ CHECK(LoggingReadFD(fd, buffer, size)); |
+} |
+ |
+void CheckedWriteFD(int fd, const void* buffer, size_t size) { |
+ CHECK(LoggingWriteFD(fd, buffer, size)); |
} |
void CheckedReadFDAtEOF(int fd) { |
@@ -110,4 +128,8 @@ bool LoggingCloseFD(int fd) { |
return rv == 0; |
} |
+void CheckedCloseFD(int fd) { |
+ CHECK(LoggingCloseFD(fd)); |
+} |
+ |
} // namespace crashpad |