misc: Fix issues identified by static analysis

Another bunch of issues addressed.
This commit is contained in:
Andreas Hansson 2014-10-01 08:05:54 -04:00
parent b520223699
commit 6498ccddb2
6 changed files with 18 additions and 6 deletions

View file

@ -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 =

View file

@ -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:

View file

@ -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;
}

View file

@ -153,7 +153,7 @@ RubySystem::writeCompressedTrace(uint8_t *raw_data, string filename,
if (gzclose(compressedMemory)) {
fatal("Close failed on memory trace file '%s'\n", filename);
}
delete raw_data;
delete[] raw_data;
}
void

View file

@ -70,6 +70,11 @@ SimObject::SimObject(const Params *p)
probeManager = new ProbeManager(this);
}
SimObject::~SimObject()
{
delete probeManager;
}
void
SimObject::init()
{

View file

@ -101,7 +101,7 @@ class SimObject : public EventManager, public Serializable, public Drainable
typedef SimObjectParams Params;
const Params *params() const { return _params; }
SimObject(const Params *_params);
virtual ~SimObject() {}
virtual ~SimObject();
public: