summaryrefslogtreecommitdiff
path: root/netlib.c
diff options
context:
space:
mode:
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);
}
}