summaryrefslogtreecommitdiff
path: root/src/arch/arm/linux
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-10-15 08:12:23 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2012-10-15 08:12:23 -0400
commit93a159875aa081cf3452754b890d83ae7c2bf943 (patch)
treeb9b1859ddcef2053f6a07c6ba7b446395686c023 /src/arch/arm/linux
parentd52adc4eb68c2733f9af4ac68834583c0a555f9d (diff)
downloadgem5-93a159875aa081cf3452754b890d83ae7c2bf943.tar.xz
Fix: Address a few minor issues identified by cppcheck
This patch addresses a number of smaller issues identified by the code inspection utility cppcheck. There are a number of identified leaks in the arm/linux/system.cc (although the function only get's called once so it is not a major problem), a few deletes in dev/x86/i8042.cc that were not array deletes, and sprintfs where the character array had one element less than needed. In the IIC tags there was a function allocating an array of longs which is in fact never used.
Diffstat (limited to 'src/arch/arm/linux')
-rw-r--r--src/arch/arm/linux/system.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/arch/arm/linux/system.cc b/src/arch/arm/linux/system.cc
index d9684fe66..1347e472d 100644
--- a/src/arch/arm/linux/system.cc
+++ b/src/arch/arm/linux/system.cc
@@ -154,40 +154,43 @@ LinuxArmSystem::initState()
warn("DTB file specified, but no device tree support in kernel\n");
}
- AtagCore *ac = new AtagCore;
- ac->flags(1); // read-only
- ac->pagesize(8192);
- ac->rootdev(0);
+ AtagCore ac;
+ ac.flags(1); // read-only
+ ac.pagesize(8192);
+ ac.rootdev(0);
AddrRangeList atagRanges = physmem.getConfAddrRanges();
if (atagRanges.size() != 1) {
fatal("Expected a single ATAG memory entry but got %d\n",
atagRanges.size());
}
- AtagMem *am = new AtagMem;
- am->memSize(atagRanges.begin()->size());
- am->memStart(atagRanges.begin()->start);
+ AtagMem am;
+ am.memSize(atagRanges.begin()->size());
+ am.memStart(atagRanges.begin()->start);
- AtagCmdline *ad = new AtagCmdline;
- ad->cmdline(params()->boot_osflags);
+ AtagCmdline ad;
+ ad.cmdline(params()->boot_osflags);
- DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str());
+ DPRINTF(Loader, "boot command line %d bytes: %s\n",
+ ad.size() <<2, params()->boot_osflags.c_str());
- AtagNone *an = new AtagNone;
+ AtagNone an;
- uint32_t size = ac->size() + am->size() + ad->size() + an->size();
+ uint32_t size = ac.size() + am.size() + ad.size() + an.size();
uint32_t offset = 0;
uint8_t *boot_data = new uint8_t[size << 2];
- offset += ac->copyOut(boot_data + offset);
- offset += am->copyOut(boot_data + offset);
- offset += ad->copyOut(boot_data + offset);
- offset += an->copyOut(boot_data + offset);
+ offset += ac.copyOut(boot_data + offset);
+ offset += am.copyOut(boot_data + offset);
+ offset += ad.copyOut(boot_data + offset);
+ offset += an.copyOut(boot_data + offset);
DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2);
DDUMP(Loader, boot_data, size << 2);
physProxy.writeBlob(params()->atags_addr, boot_data, size << 2);
+
+ delete[] boot_data;
}
for (int i = 0; i < threadContexts.size(); i++) {