diff options
author | Ian Lance Taylor <iant@google.com> | 2007-12-20 21:26:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-12-20 21:26:17 +0000 |
commit | 8cce67184345ae550d224ed2382f9aa65ac54c8a (patch) | |
tree | 2c7ebee6e29cdde1a85e9e2a5146e1df0c9f4f73 /gold/fileread.cc | |
parent | fe8718a4637d92b3cd991a8f1a22d6d0a09bc6dd (diff) | |
download | gdb-8cce67184345ae550d224ed2382f9aa65ac54c8a.zip gdb-8cce67184345ae550d224ed2382f9aa65ac54c8a.tar.gz gdb-8cce67184345ae550d224ed2382f9aa65ac54c8a.tar.bz2 |
Fix buglet in last patch.
Diffstat (limited to 'gold/fileread.cc')
-rw-r--r-- | gold/fileread.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gold/fileread.cc b/gold/fileread.cc index 31f48a4..baa681a 100644 --- a/gold/fileread.cc +++ b/gold/fileread.cc @@ -208,11 +208,11 @@ File_read::find_view(off_t start, section_size_type size) const void File_read::do_read(off_t start, section_size_type size, void* p) const { - section_size_type bytes; + ssize_t bytes; if (this->contents_ != NULL) { bytes = this->size_ - start; - if (bytes >= size) + if (static_cast<section_size_type>(bytes) >= size) { memcpy(p, this->contents_ + start, size); return; @@ -220,16 +220,16 @@ File_read::do_read(off_t start, section_size_type size, void* p) const } else { - ssize_t got = ::pread(this->descriptor_, p, size, start); - if (got < 0) + bytes = ::pread(this->descriptor_, p, size, start); + if (static_cast<section_size_type>(bytes) == size) + return; + + if (bytes < 0) { gold_fatal(_("%s: pread failed: %s"), this->filename().c_str(), strerror(errno)); return; } - - if (static_cast<section_size_type>(got) == size) - return; } gold_fatal(_("%s: file too short: read only %lld of %lld bytes at %lld"), |