Skip to content

Commit b4e67d6

Browse files
SocketWrapper: removing close() because directly managed by shared_ptr
1 parent 2a941c7 commit b4e67d6

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

libraries/SocketWrapper/SocketWrapper.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class ZephyrSocketWrapper {
7474
}
7575

7676
if (::connect(*sock_fd, res->ai_addr, res->ai_addrlen) < 0) {
77-
::close(*sock_fd);
78-
*sock_fd = -1;
77+
sock_fd = nullptr;
7978
rv = false;
8079
goto exit;
8180
}
@@ -107,8 +106,7 @@ class ZephyrSocketWrapper {
107106
}
108107

109108
if (::connect(*sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
110-
::close(*sock_fd);
111-
*sock_fd = -1;
109+
sock_fd = nullptr;
112110
return false;
113111
}
114112

@@ -188,8 +186,7 @@ class ZephyrSocketWrapper {
188186
}
189187

190188
if (!rv && *sock_fd >= 0) {
191-
::close(*sock_fd);
192-
*sock_fd = -1;
189+
sock_fd = nullptr;
193190
}
194191
return rv;
195192
}
@@ -244,8 +241,7 @@ class ZephyrSocketWrapper {
244241

245242
void close() {
246243
if (sock_fd && *sock_fd != -1) {
247-
::close(*sock_fd);
248-
*sock_fd = -1;
244+
sock_fd = nullptr;
249245
}
250246
}
251247

@@ -266,8 +262,7 @@ class ZephyrSocketWrapper {
266262
zsock_ioctl(*sock_fd, ZFD_IOCTL_FIONBIO);
267263

268264
if (::bind(*sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
269-
::close(*sock_fd);
270-
*sock_fd = -1;
265+
sock_fd = nullptr;
271266
return false;
272267
}
273268

@@ -280,8 +275,7 @@ class ZephyrSocketWrapper {
280275
}
281276

282277
if (::listen(*sock_fd, backlog) < 0) {
283-
::close(*sock_fd);
284-
*sock_fd = -1;
278+
sock_fd = nullptr;
285279
return false;
286280
}
287281

0 commit comments

Comments
 (0)