ARMmbed / sockets

mbed sockets library abstraction layer
Other
6 stars 18 forks source link

Documentation and error checking omissions #48

Closed adbridge closed 8 years ago

adbridge commented 8 years ago
  1. send_to() a) Implementation returns a specific error code if the socket is not open but this is not documented in the header. b) Header specifies that the method is not valid for SOCK_STREAM so should probably state what the error condition returned is if SOCK_STREAM does get used? c) Should check that remote_addr is not NULL before dereferencing in the implementation
  2. send() a) Implementation returns a specific error code if the socket is not open but this is not documented in the header. b) Documentation says that this method is not valid for UDP unless connect() has previously been called. Should document the expected error returned if this is not the case.
  3. recv () a) Implementation returns a specific error code if the socket is not open but this is not documented in the header.
  4. recv_from() a) Implementation returns a specific error code if the socket is not open but this is not documented in the header. b) Should check that remote_addr is not NULL before dereferencing

5 General Any pointer dereferenced directly within the method implementation should be checked for being non-NULL before dereferencing. Any pointers passed down to the API do not need to be checked as it can be the responsibility of the API to do so.

ciarmcom commented 8 years ago

ARM Internal Ref: IOTSFW-1510

adbridge commented 8 years ago
  1. resolve()

The documentation states that the socket must have been opened before the resolve is called. Other methods check for the 'impl' to be non NULL when checking if a socket is open. The implementation for this method instead checks if _socket.handler != NULL. This is inconsistent . The error reported by this check is SOCKET_ERROR_CLOSED, which is also inconsistent for a non opened socket. To be consistent with other methods the following code should be used :-

    if (_socket.impl == NULL) {
        return SOCKET_ERROR_NULL_PTR;

If the current check is actually for an additional error case then it should be kept and documented accordingly, with the addition of the above check.