From d66b14ca61bec95a4049e5aae468904395055efd Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 24 Nov 2014 09:03:38 -0500 Subject: [PATCH] misc: Another round of static analysis fixups Mostly addressing uninitialised members. --- src/base/bigint.hh | 9 +++------ src/base/remote_gdb.cc | 5 +++-- src/dev/virtio/base.cc | 3 ++- src/dev/virtio/base.hh | 2 +- src/dev/virtio/fs9p.cc | 2 +- src/dev/virtio/pci.cc | 4 ++-- src/mem/external_slave.cc | 2 +- src/sim/insttracer.hh | 9 +++------ src/sim/process.cc | 2 ++ src/sim/syscall_emul.cc | 6 +++--- 10 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/base/bigint.hh b/src/base/bigint.hh index a4e8738d3..2fa441a73 100644 --- a/src/base/bigint.hh +++ b/src/base/bigint.hh @@ -39,13 +39,10 @@ struct m5_twin64_t { uint64_t a; uint64_t b; - m5_twin64_t() + m5_twin64_t() : a(0), b(0) + {} + m5_twin64_t(const uint64_t x) : a(x), b(x) {} - m5_twin64_t(const uint64_t x) - { - a = x; - b = x; - } inline m5_twin64_t& operator=(const uint64_t x) { a = x; diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index 49b7ce50d..ead8db9ae 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -658,12 +658,13 @@ BaseRemoteGDB::trap(int type) * After the debugger is "active" (connected) it will be * waiting for a "signaled" message from us. */ - if (!active) + if (!active) { active = true; - else + } else { // Tell remote host that an exception has occurred. snprintf((char *)buffer, bufferSize, "S%02x", type); send(buffer); + } // Stick frame regs into our reg cache. getregs(); diff --git a/src/dev/virtio/base.cc b/src/dev/virtio/base.cc index 79304cf1d..44cce65c4 100644 --- a/src/dev/virtio/base.cc +++ b/src/dev/virtio/base.cc @@ -43,7 +43,8 @@ VirtDescriptor::VirtDescriptor(PortProxy &_memProxy, VirtQueue &_queue, Index descIndex) - : memProxy(&_memProxy), queue(&_queue), _index(descIndex) + : memProxy(&_memProxy), queue(&_queue), _index(descIndex), + desc{0, 0, 0, 0} { } diff --git a/src/dev/virtio/base.hh b/src/dev/virtio/base.hh index 4695f2b96..fe1685767 100644 --- a/src/dev/virtio/base.hh +++ b/src/dev/virtio/base.hh @@ -479,7 +479,7 @@ public: } M5_ATTR_PACKED; VirtRing(PortProxy &proxy, uint16_t size) - : ring(size), _proxy(proxy), _base(0) {} + : header{0, 0}, ring(size), _proxy(proxy), _base(0) {} /** * Set the base address of the VirtIO ring buffer. diff --git a/src/dev/virtio/fs9p.cc b/src/dev/virtio/fs9p.cc index b09ab15aa..4861821d7 100644 --- a/src/dev/virtio/fs9p.cc +++ b/src/dev/virtio/fs9p.cc @@ -291,7 +291,7 @@ VirtIO9PProxy::writeAll(const uint8_t *data, size_t len) VirtIO9PDiod::VirtIO9PDiod(Params *params) : VirtIO9PProxy(params), - fd_to_diod(-1), fd_from_diod(-1) + fd_to_diod(-1), fd_from_diod(-1), diod_pid(-1) { } diff --git a/src/dev/virtio/pci.cc b/src/dev/virtio/pci.cc index 399590c1b..1f99d7fe4 100644 --- a/src/dev/virtio/pci.cc +++ b/src/dev/virtio/pci.cc @@ -43,8 +43,8 @@ #include "params/PciVirtIO.hh" PciVirtIO::PciVirtIO(const Params *params) - : PciDevice(params), vio(*params->vio), - callbackKick(this) + : PciDevice(params), queueNotify(0), interruptDeliveryPending(false), + vio(*params->vio), callbackKick(this) { // Override the subsystem ID with the device ID from VirtIO config.subsystemID = htole(vio.deviceId); diff --git a/src/mem/external_slave.cc b/src/mem/external_slave.cc index c7ad521c9..c2ec8e2e4 100644 --- a/src/mem/external_slave.cc +++ b/src/mem/external_slave.cc @@ -73,7 +73,7 @@ class StubSlavePort : public ExternalSlave::Port StubSlavePort(const std::string &name_, ExternalSlave &owner_) : ExternalSlave::Port(name_, owner_), - responseEvent(*this), responsePacket(NULL) + responseEvent(*this), responsePacket(NULL), mustRetry(false) { } Tick recvAtomic(PacketPtr packet); diff --git a/src/sim/insttracer.hh b/src/sim/insttracer.hh index 596712120..df1f12766 100644 --- a/src/sim/insttracer.hh +++ b/src/sim/insttracer.hh @@ -94,13 +94,10 @@ class InstRecord : when(_when), thread(_thread), staticInst(_staticInst), pc(_pc), macroStaticInst(_macroStaticInst), - misspeculating(spec), predicate(true) + misspeculating(spec), predicate(true), addr(0), addr_valid(false), + data_status(DataInvalid), + fetch_seq(0), fetch_seq_valid(false), cp_seq(0), cp_seq_valid(false) { - data_status = DataInvalid; - addr_valid = false; - - fetch_seq_valid = false; - cp_seq_valid = false; } virtual ~InstRecord() { } diff --git a/src/sim/process.cc b/src/sim/process.cc index 0412c27e0..2e5f64497 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -104,7 +104,9 @@ template struct AuxVector; Process::Process(ProcessParams * params) : SimObject(params), system(params->system), + brk_point(0), stack_base(0), stack_size(0), stack_min(0), max_stack_size(params->max_stack_size), + next_thread_stack_base(0), M5_pid(system->allocatePID()), useArchPT(params->useArchPT), kvmInSE(params->kvmInSE), diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index cb592e338..37d0121c5 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -228,6 +228,7 @@ readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) { int index = 0; int fd = p->sim_fd(p->getSyscallArg(tc, index)); + assert(fd >= 0); Addr bufPtr = p->getSyscallArg(tc, index); int nbytes = p->getSyscallArg(tc, index); BufferArg bufArg(bufPtr, nbytes); @@ -264,6 +265,7 @@ lseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) { int index = 0; int fd = p->sim_fd(p->getSyscallArg(tc, index)); + assert(fd >= 0); uint64_t offs = p->getSyscallArg(tc, index); int whence = p->getSyscallArg(tc, index); @@ -278,6 +280,7 @@ _llseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) { int index = 0; int fd = p->sim_fd(p->getSyscallArg(tc, index)); + assert(fd >= 0); uint64_t offset_high = p->getSyscallArg(tc, index); uint32_t offset_low = p->getSyscallArg(tc, index); Addr result_ptr = p->getSyscallArg(tc, index); @@ -301,9 +304,6 @@ _llseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) result_buf.copyOut(tc->getMemProxy()); return 0; } - - - return (result == (off_t)-1) ? -errno : result; } -- 2.30.2