summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-10-01 08:05:54 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2014-10-01 08:05:54 -0400
commit6498ccddb2f13a6fac6a210372b1aa86873507b9 (patch)
treed8fa5ac5e99c01df46d71c3c87e87d2114bfe088 /src/base
parentb520223699f51562140b8cc4a922eae64dffb3e3 (diff)
downloadgem5-6498ccddb2f13a6fac6a210372b1aa86873507b9.tar.xz
misc: Fix issues identified by static analysis
Another bunch of issues addressed.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/loader/object_file.cc7
-rw-r--r--src/base/statistics.hh3
-rw-r--r--src/base/vnc/vncserver.cc5
3 files changed, 11 insertions, 4 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 =
diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 1b3d0fc54..a6edde2f9 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -1361,7 +1361,8 @@ class DistStor
/** The number of buckets. Equal to (max-min)/bucket_size. */
size_type buckets;
- Params() : DistParams(Dist) {}
+ Params() : DistParams(Dist), min(0), max(0), bucket_size(0),
+ buckets(0) {}
};
private:
diff --git a/src/base/vnc/vncserver.cc b/src/base/vnc/vncserver.cc
index e762ad1d4..77a4316ab 100644
--- a/src/base/vnc/vncserver.cc
+++ b/src/base/vnc/vncserver.cc
@@ -184,6 +184,8 @@ VncServer::accept()
panic("%s: cannot accept a connection if not listening!", name());
int fd = listener.accept(true);
+ fatal_if(fd < 0, "%s: failed to accept VNC connection!", name());
+
if (dataFd != -1) {
char message[] = "vnc server already attached!\n";
atomic_write(fd, message, sizeof(message));
@@ -643,7 +645,8 @@ VncServer::sendFrameBufferUpdate()
assert(fbPtr);
uint8_t *tmp = vc->convert(fbPtr);
- write(tmp, videoWidth() * videoHeight() * sizeof(uint32_t));
+ uint64_t num_pixels = videoWidth() * videoHeight();
+ write(tmp, num_pixels * sizeof(uint32_t));
delete [] tmp;
}