diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2014-10-01 08:05:54 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2014-10-01 08:05:54 -0400 |
commit | 6498ccddb2f13a6fac6a210372b1aa86873507b9 (patch) | |
tree | d8fa5ac5e99c01df46d71c3c87e87d2114bfe088 /src/base/loader | |
parent | b520223699f51562140b8cc4a922eae64dffb3e3 (diff) | |
download | gem5-6498ccddb2f13a6fac6a210372b1aa86873507b9.tar.xz |
misc: Fix issues identified by static analysis
Another bunch of issues addressed.
Diffstat (limited to 'src/base/loader')
-rw-r--r-- | src/base/loader/object_file.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/base/loader/object_file.cc b/src/base/loader/object_file.cc index 170e18d5e..29cea8ccf 100644 --- a/src/base/loader/object_file.cc +++ b/src/base/loader/object_file.cc @@ -54,7 +54,8 @@ ObjectFile::ObjectFile(const string &_filename, int _fd, size_t _len, uint8_t *_data, Arch _arch, OpSys _opSys) : filename(_filename), descriptor(_fd), fileData(_data), len(_len), - arch(_arch), opSys(_opSys), globalPtr(0) + arch(_arch), opSys(_opSys), entry(0), globalPtr(0), + text{0, nullptr, 0}, data{0, nullptr, 0}, bss{0, nullptr, 0} { } @@ -116,7 +117,9 @@ createObjectFile(const string &fname, bool raw) } // find the length of the file by seeking to the end - size_t len = (size_t)lseek(fd, 0, SEEK_END); + off_t off = lseek(fd, 0, SEEK_END); + fatal_if(off < 0, "Failed to determine size of object file %s\n", fname); + size_t len = static_cast<size_t>(off); // mmap the whole shebang uint8_t *fileData = |