From 93a159875aa081cf3452754b890d83ae7c2bf943 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 15 Oct 2012 08:12:23 -0400 Subject: 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. --- src/arch/arm/linux/system.cc | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/arch/arm') 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++) { -- cgit v1.2.3