diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2014-09-27 09:08:29 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2014-09-27 09:08:29 -0400 |
commit | de62aedabc96e7492c40bbc4468ba42b3274bfd6 (patch) | |
tree | e68dae6dd1f3da0e7d2dcf3e946728c46e63bbce /src/base/socket.cc | |
parent | 71d5f03175b3a684b94bbc515ebc02e2b493b7cf (diff) | |
download | gem5-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/socket.cc')
-rw-r--r-- | src/base/socket.cc | 7 |
1 files changed, 5 insertions, 2 deletions
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; |