summaryrefslogtreecommitdiff
path: root/src/base
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/base
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/base')
-rw-r--r--src/base/output.cc2
-rw-r--r--src/base/socket.cc7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/base/output.cc b/src/base/output.cc
index 912ec20e9..da9a551fa 100644
--- a/src/base/output.cc
+++ b/src/base/output.cc
@@ -255,6 +255,8 @@ OutputDirectory::remove(const string &name, bool recursive)
de = readdir(subdir);
}
+
+ closedir(subdir);
}
// try to force recognition that we deleted the files in the directory
diff --git a/src/base/socket.cc b/src/base/socket.cc
index c39accd7e..01fb519b4 100644
--- a/src/base/socket.cc
+++ b/src/base/socket.cc
@@ -94,8 +94,9 @@ ListenSocket::listen(int port, bool reuse)
struct sockaddr_in sockaddr;
sockaddr.sin_family = PF_INET;
sockaddr.sin_addr.s_addr = INADDR_ANY;
-
sockaddr.sin_port = htons(port);
+ // finally clear sin_zero
+ memset(&sockaddr.sin_zero, 0, sizeof(sockaddr.sin_zero));
int ret = ::bind(fd, (struct sockaddr *)&sockaddr, sizeof (sockaddr));
if (ret != 0) {
if (ret == -1 && errno != EADDRINUSE)
@@ -126,7 +127,9 @@ ListenSocket::accept(bool nodelay)
int sfd = ::accept(fd, (struct sockaddr *)&sockaddr, &slen);
if (sfd != -1 && nodelay) {
int i = 1;
- ::setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (char *)&i, sizeof(i));
+ if (::setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (char *)&i,
+ sizeof(i)) < 0)
+ warn("ListenSocket(accept): setsockopt() TCP_NODELAY failed!");
}
return sfd;