Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: util/file/string_file.cc

Issue 1416493006: Change file op |ssize_t|s to FileOperationResult (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/file/string_file.h ('k') | util/file/string_file_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/string_file.cc
diff --git a/util/file/string_file.cc b/util/file/string_file.cc
index 061b275b0cd5c30a9f1fcc248ec6c194e55b2edf..1c74b3f0c0169a347a86977f87f101c67defc6bc 100644
--- a/util/file/string_file.cc
+++ b/util/file/string_file.cc
@@ -33,8 +33,9 @@ StringFile::~StringFile() {
}
void StringFile::SetString(const std::string& string) {
- CHECK_LE(string.size(),
- implicit_cast<size_t>(std::numeric_limits<ssize_t>::max()));
+ CHECK_LE(
+ string.size(),
+ implicit_cast<size_t>(std::numeric_limits<FileOperationResult>::max()));
string_ = string;
offset_ = 0;
}
@@ -44,7 +45,7 @@ void StringFile::Reset() {
offset_ = 0;
}
-ssize_t StringFile::Read(void* data, size_t size) {
+FileOperationResult StringFile::Read(void* data, size_t size) {
DCHECK(offset_.IsValid());
const size_t offset = offset_.ValueOrDie();
@@ -54,7 +55,7 @@ ssize_t StringFile::Read(void* data, size_t size) {
const size_t nread = std::min(size, string_.size() - offset);
- base::CheckedNumeric<ssize_t> new_offset = offset_;
+ base::CheckedNumeric<FileOperationResult> new_offset = offset_;
new_offset += nread;
if (!new_offset.IsValid()) {
LOG(ERROR) << "Read(): file too large";
@@ -75,7 +76,7 @@ bool StringFile::Write(const void* data, size_t size) {
string_.resize(offset);
}
- base::CheckedNumeric<ssize_t> new_offset = offset_;
+ base::CheckedNumeric<FileOperationResult> new_offset = offset_;
new_offset += size;
if (!new_offset.IsValid()) {
LOG(ERROR) << "Write(): file too large";
@@ -97,7 +98,7 @@ bool StringFile::WriteIoVec(std::vector<WritableIoVec>* iovecs) {
}
// Avoid writing anything at all if it would cause an overflow.
- base::CheckedNumeric<ssize_t> new_offset = offset_;
+ base::CheckedNumeric<FileOperationResult> new_offset = offset_;
for (const WritableIoVec& iov : *iovecs) {
new_offset += iov.iov_len;
if (!new_offset.IsValid()) {
« no previous file with comments | « util/file/string_file.h ('k') | util/file/string_file_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698