Skip to content

Commit e7cb475

Browse files
author
Seppo Takalo
committed
Fix small issues from the review
1 parent 2b60e42 commit e7cb475

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

features/netsocket/SocketAddress.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ class SocketAddress {
114114
*/
115115
void set_port(uint16_t port);
116116

117-
/** Get the human readable IP address
117+
/** Get the human-readable IP address
118118
*
119119
* Allocates memory for a string and converts binary address to
120-
* human readable format. String is freed in the destructor.
120+
* human-readable format. String is freed in the destructor.
121121
*
122122
* @return Null-terminated representation of the IP Address
123123
*/
@@ -153,7 +153,7 @@ class SocketAddress {
153153
*/
154154
operator bool() const;
155155

156-
/** Copy addres from another SocketAddress
156+
/** Copy address from another SocketAddress
157157
*
158158
* @param addr SocketAddress to copy
159159
*/

features/netsocket/TCPSocket.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,22 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
249249
{
250250
_lock.lock();
251251
TCPSocket *connection = NULL;
252+
nsapi_error_t ret;
252253

253254
_readers++;
254255

255256
while (true) {
256257
if (!_socket) {
257-
*error = NSAPI_ERROR_NO_SOCKET;
258+
ret = NSAPI_ERROR_NO_SOCKET;
258259
break;
259260
}
260261

261262
_pending = 0;
262263
void *socket;
263264
SocketAddress address;
264-
*error = _stack->socket_accept(_socket, &socket, &address);
265+
ret = _stack->socket_accept(_socket, &socket, &address);
265266

266-
if (0 == *error) {
267+
if (0 == ret) {
267268
TCPSocket *connection = new TCPSocket();
268269
connection->_lock.lock();
269270
connection->_factory_allocated = true; // Destroy automatically on close()
@@ -275,7 +276,7 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
275276

276277
connection->_lock.unlock();
277278
break;
278-
} else if ((_timeout == 0) || (*error != NSAPI_ERROR_WOULD_BLOCK)) {
279+
} else if ((_timeout == 0) || (ret != NSAPI_ERROR_WOULD_BLOCK)) {
279280
break;
280281
} else {
281282
uint32_t flag;
@@ -288,7 +289,7 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
288289

289290
if (flag & osFlagsError) {
290291
// Timeout break
291-
*error = NSAPI_ERROR_WOULD_BLOCK;
292+
ret = NSAPI_ERROR_WOULD_BLOCK;
292293
break;
293294
}
294295
}
@@ -299,5 +300,8 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
299300
_event_flag.set(FINISHED_FLAG);
300301
}
301302
_lock.unlock();
303+
if (error) {
304+
*error = ret;
305+
}
302306
return connection;
303307
}

features/netsocket/UDPSocket.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ nsapi_protocol_t UDPSocket::get_proto()
3434

3535
nsapi_error_t UDPSocket::connect(const SocketAddress &address)
3636
{
37-
if (!address)
38-
return NSAPI_ERROR_PARAMETER;
3937
_remote_peer = address;
4038
return NSAPI_ERROR_OK;
4139
}

0 commit comments

Comments
 (0)