diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2013-04-17 08:17:03 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2013-04-17 08:17:03 -0400 |
commit | 234c9a36a21fae7c0489e2f67b8e0385e61db732 (patch) | |
tree | 33e9e1caf1befcb6c456c00d3ef548c4ba8a8020 /src | |
parent | c704b7be16cc46e1f57968ee5fd3d78de89135a5 (diff) | |
download | gem5-234c9a36a21fae7c0489e2f67b8e0385e61db732.tar.xz |
dev: Fix a bug in the use of seekp/seekg
This patch fixes two instances of incorrect use of the seekp/seekg
stream member functions. These two functions return a stream reference
(*this), and should not be compared to an integer value.
Diffstat (limited to 'src')
-rw-r--r-- | src/dev/disk_image.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dev/disk_image.cc b/src/dev/disk_image.cc index 84027d9b4..8194eb507 100644 --- a/src/dev/disk_image.cc +++ b/src/dev/disk_image.cc @@ -108,7 +108,8 @@ RawDiskImage::read(uint8_t *data, std::streampos offset) const if (!stream.is_open()) panic("file not open!\n"); - if (stream.seekg(offset * SectorSize, ios::beg) < 0) + stream.seekg(offset * SectorSize, ios::beg); + if (!stream.good()) panic("Could not seek to location in file"); streampos pos = stream.tellg(); @@ -132,7 +133,8 @@ RawDiskImage::write(const uint8_t *data, std::streampos offset) if (!stream.is_open()) panic("file not open!\n"); - if (stream.seekp(offset * SectorSize, ios::beg) < 0) + stream.seekp(offset * SectorSize, ios::beg); + if (!stream.good()) panic("Could not seek to location in file"); DPRINTF(DiskImageWrite, "write: offset=%d\n", (uint64_t)offset); |