summaryrefslogtreecommitdiff
path: root/src/mem/physical.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-09-27 09:08:29 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2014-09-27 09:08:29 -0400
commitde62aedabc96e7492c40bbc4468ba42b3274bfd6 (patch)
treee68dae6dd1f3da0e7d2dcf3e946728c46e63bbce /src/mem/physical.cc
parent71d5f03175b3a684b94bbc515ebc02e2b493b7cf (diff)
downloadgem5-de62aedabc96e7492c40bbc4468ba42b3274bfd6.tar.xz
misc: Fix a bunch of minor issues identified by static analysis
Add some missing initialisation, and fix a handful benign resource leaks (including some false positives).
Diffstat (limited to 'src/mem/physical.cc')
-rw-r--r--src/mem/physical.cc22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/mem/physical.cc b/src/mem/physical.cc
index 08ec83410..398d0530f 100644
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -307,16 +307,9 @@ PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
// write memory file
string filepath = Checkpoint::dir() + "/" + filename.c_str();
- int fd = creat(filepath.c_str(), 0664);
- if (fd < 0) {
- perror("creat");
- fatal("Can't open physical memory checkpoint file '%s'\n",
- filename);
- }
-
- gzFile compressed_mem = gzdopen(fd, "wb");
+ gzFile compressed_mem = gzopen(filepath.c_str(), "wb");
if (compressed_mem == NULL)
- fatal("Insufficient memory to allocate compression state for %s\n",
+ fatal("Can't open physical memory checkpoint file '%s'\n",
filename);
uint64_t pass_size = 0;
@@ -380,16 +373,9 @@ PhysicalMemory::unserializeStore(Checkpoint* cp, const string& section)
string filepath = cp->cptDir + "/" + filename;
// mmap memoryfile
- int fd = open(filepath.c_str(), O_RDONLY);
- if (fd < 0) {
- perror("open");
- fatal("Can't open physical memory checkpoint file '%s'", filename);
- }
-
- gzFile compressed_mem = gzdopen(fd, "rb");
+ gzFile compressed_mem = gzopen(filepath.c_str(), "rb");
if (compressed_mem == NULL)
- fatal("Insufficient memory to allocate compression state for %s\n",
- filename);
+ fatal("Can't open physical memory checkpoint file '%s'", filename);
// we've already got the actual backing store mapped
uint8_t* pmem = backingStore[store_id].second;