Skip to content

Commit 9bd4b06

Browse files
SocketWrapper: removing close() because directly managed by shared_ptr
1 parent 8e3327c commit 9bd4b06

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

libraries/SocketWrapper/SocketWrapper.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class ZephyrSocketWrapper {
8080
}
8181

8282
if (::connect(*sock_fd, res->ai_addr, res->ai_addrlen) < 0) {
83-
::close(*sock_fd);
84-
*sock_fd = -1;
83+
sock_fd = nullptr;
8584
rv = false;
8685
goto exit;
8786
}
@@ -113,8 +112,7 @@ class ZephyrSocketWrapper {
113112
}
114113

115114
if (::connect(*sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
116-
::close(*sock_fd);
117-
*sock_fd = -1;
115+
sock_fd = nullptr;
118116
return false;
119117
}
120118

@@ -194,8 +192,7 @@ class ZephyrSocketWrapper {
194192
}
195193

196194
if (!rv && *sock_fd >= 0) {
197-
::close(*sock_fd);
198-
*sock_fd = -1;
195+
sock_fd = nullptr;
199196
}
200197
return rv;
201198
}
@@ -250,8 +247,7 @@ class ZephyrSocketWrapper {
250247

251248
void close() {
252249
if (sock_fd && *sock_fd != -1) {
253-
::close(*sock_fd);
254-
*sock_fd = -1;
250+
sock_fd = nullptr;
255251
}
256252
}
257253

@@ -272,8 +268,7 @@ class ZephyrSocketWrapper {
272268
zsock_ioctl(*sock_fd, ZFD_IOCTL_FIONBIO);
273269

274270
if (::bind(*sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
275-
::close(*sock_fd);
276-
*sock_fd = -1;
271+
sock_fd = nullptr;
277272
return false;
278273
}
279274

@@ -286,8 +281,7 @@ class ZephyrSocketWrapper {
286281
}
287282

288283
if (::listen(*sock_fd, backlog) < 0) {
289-
::close(*sock_fd);
290-
*sock_fd = -1;
284+
sock_fd = nullptr;
291285
return false;
292286
}
293287

0 commit comments

Comments
 (0)