summaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-12-20 21:26:17 +0000
committerIan Lance Taylor <iant@google.com>2007-12-20 21:26:17 +0000
commit357fb635f531385d0522f1925d931ef8d51ecfc0 (patch)
treeedccced84a262ab847d5f68e1bda2ab4e98eb7d2 /gold
parentb693d6d991bca747f15b5dfbfbfdd61998848065 (diff)
downloadbinutils-redhat-357fb635f531385d0522f1925d931ef8d51ecfc0.tar.gz
Fix buglet in last patch.
Diffstat (limited to 'gold')
-rw-r--r--gold/fileread.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 31f48a4462..baa681a24c 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"),