Skip to content

Commit c80ccfa

Browse files
SocketWrapper: fix sock_fd check condition
1 parent b4e67d6 commit c80ccfa

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

libraries/SocketWrapper/SocketWrapper.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ZephyrSocketWrapper {
6767
raw_sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
6868
sock_fd = std::shared_ptr<int>(raw_sock_fd < 0 ? nullptr : new int(raw_sock_fd),
6969
socket_deleter());
70-
if (!sock_fd || *sock_fd < 0) {
70+
if (!sock_fd) {
7171
rv = false;
7272

7373
goto exit;
@@ -101,7 +101,7 @@ class ZephyrSocketWrapper {
101101
raw_sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
102102
sock_fd = std::shared_ptr<int>(raw_sock_fd < 0 ? nullptr : new int(raw_sock_fd),
103103
socket_deleter());
104-
if (!sock_fd || *sock_fd < 0) {
104+
if (!sock_fd) {
105105
return false;
106106
}
107107

@@ -162,7 +162,7 @@ class ZephyrSocketWrapper {
162162
raw_sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TLS_1_2);
163163
sock_fd = std::shared_ptr<int>(raw_sock_fd < 0 ? nullptr : new int(raw_sock_fd),
164164
socket_deleter());
165-
if (!sock_fd || *sock_fd < 0) {
165+
if (!sock_fd) {
166166
goto exit;
167167
}
168168

@@ -240,7 +240,7 @@ class ZephyrSocketWrapper {
240240
}
241241

242242
void close() {
243-
if (sock_fd && *sock_fd != -1) {
243+
if (sock_fd) {
244244
sock_fd = nullptr;
245245
}
246246
}
@@ -255,7 +255,7 @@ class ZephyrSocketWrapper {
255255
raw_sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
256256
sock_fd = std::shared_ptr<int>(raw_sock_fd < 0 ? nullptr : new int(raw_sock_fd),
257257
socket_deleter());
258-
if (!sock_fd || *sock_fd < 0) {
258+
if (!sock_fd) {
259259
return false;
260260
}
261261

libraries/SocketWrapper/ZephyrClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ZephyrClient : public arduino::Client, ZephyrSocketWrapper {
9898
}
9999

100100
operator bool() {
101-
return sock_fd && *sock_fd != -1;
101+
return sock_fd;
102102
}
103103

104104
String remoteIP() {

libraries/SocketWrapper/ZephyrServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ZephyrServer : public arduino::Server, ZephyrSocketWrapper {
3636
}
3737

3838
explicit operator bool() {
39-
return sock_fd && *sock_fd != -1;
39+
return sock_fd;
4040
}
4141

4242
ZephyrClient accept(uint8_t *status = nullptr) {

0 commit comments

Comments
 (0)