summaryrefslogtreecommitdiff
path: root/netlib.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-06 14:13:06 -0500
committerEric S. Raymond <esr@thyrsus.com>2013-11-06 14:13:06 -0500
commit6a70ad85340b25b5e3a224d61e4cee7277333969 (patch)
treefa7ec24ea268fb1fd5d6f611b8931320681bb87b /netlib.c
parenta7280f885cdc98b06c505a8ea4e4db9bd712ca36 (diff)
downloadgpsd-6a70ad85340b25b5e3a224d61e4cee7277333969.tar.gz
cppcheck and Coverity cleanup (not yet complete).
All regression tests pass. PPS is live.
Diffstat (limited to 'netlib.c')
-rw-r--r--netlib.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/netlib.c b/netlib.c
index 4be2660a..36921441 100644
--- a/netlib.c
+++ b/netlib.c
@@ -30,10 +30,9 @@ socket_t netlib_connectsock(int af, const char *host, const char *service,
struct addrinfo hints;
struct addrinfo *result, *rp;
int ret, type, proto, one = 1;
- socket_t s = -1;
+ socket_t s;
bool bind_me;
- /* cppcheck-suppress redundantAssignment */
INVALIDATE_SOCKET(s);
/*@-type@*/
ppe = getprotobyname(protocol);
@@ -79,8 +78,6 @@ socket_t netlib_connectsock(int af, const char *host, const char *service,
else if (setsockopt
(s, SOL_SOCKET, SO_REUSEADDR, (char *)&one,
sizeof(one)) == -1) {
- if (s > -1)
- (void)close(s);
ret = NL_NOSOCKOPT;
} else {
if (bind_me) {
@@ -96,7 +93,7 @@ socket_t netlib_connectsock(int af, const char *host, const char *service,
}
}
- if (s > -1) {
+ if (!BAD_SOCKET(s)) {
(void)close(s);
}
}