Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 727f04f in mainline


Ignore:
Timestamp:
2010-12-27T19:30:20Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
45bb1d2
Parents:
d493830e
Message:

recv() and recvfrom() should return ssize_t.

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/socket_client.c

    rd493830e r727f04f  
    966966 *                      read. The actual address length is set. Used only if
    967967 *                      fromaddr is not NULL.
    968  * @return              EOK on success.
     968 * @return              Positive received message size in bytes on success.
     969 * @return              Zero if no more data (other side closed the connection).
    969970 * @return              ENOTSOCK if the socket is not found.
    970971 * @return              EBADMEM if the data parameter is NULL.
     
    972973 * @return              Other error codes as defined for the spcific message.
    973974 */
    974 static int
     975static ssize_t
    975976recvfrom_core(sysarg_t message, int socket_id, void *data, size_t datalength,
    976977    int flags, struct sockaddr *fromaddr, socklen_t *addrlen)
     
    984985        size_t index;
    985986        ipc_call_t answer;
     987        ssize_t retval;
    986988
    987989        if (!data)
     
    10831085                dyn_fifo_pop(&socket->received);
    10841086                // return read data length
    1085                 result = SOCKET_GET_READ_DATA_LENGTH(answer);
     1087                retval = SOCKET_GET_READ_DATA_LENGTH(answer);
    10861088                // set address length
    10871089                if (fromaddr && addrlen)
    10881090                        *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer);
     1091        } else {
     1092                retval = (ssize_t) result;
    10891093        }
    10901094
    10911095        fibril_mutex_unlock(&socket->receive_lock);
    10921096        fibril_rwlock_read_unlock(&socket_globals.lock);
    1093         return result;
     1097        return retval;
    10941098}
    10951099
     
    11001104 * @param[in] datalength The data length.
    11011105 * @param[in] flags     Various receive flags.
    1102  * @return              EOK on success.
     1106 * @return              Positive received message size in bytes on success.
     1107 * @return              Zero if no more data (other side closed the connection).
    11031108 * @return              ENOTSOCK if the socket is not found.
    11041109 * @return              EBADMEM if the data parameter is NULL.
     
    11071112 *                      message.
    11081113 */
    1109 int recv(int socket_id, void *data, size_t datalength, int flags)
     1114ssize_t recv(int socket_id, void *data, size_t datalength, int flags)
    11101115{
    11111116        // without the address
     
    11231128 * @param[in,out] addrlen The address length. The maximum address length is
    11241129 *                      read. The actual address length is set.
    1125  * @return              EOK on success.
     1130 * @return              Positive received message size in bytes on success.
     1131 * @return              Zero if no more data (other side closed the connection).
    11261132 * @return              ENOTSOCK if the socket is not found.
    11271133 * @return              EBADMEM if the data or fromaddr parameter is NULL.
     
    11301136 *                      message.
    11311137 */
    1132 int
     1138ssize_t
    11331139recvfrom(int socket_id, void *data, size_t datalength, int flags,
    11341140    struct sockaddr *fromaddr, socklen_t *addrlen)
  • uspace/lib/c/include/net/socket.h

    rd493830e r727f04f  
    6060extern int sendto(int, const void *, size_t, int, const struct sockaddr *,
    6161    socklen_t);
    62 extern int recv(int, void *, size_t, int);
    63 extern int recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
     62extern ssize_t recv(int, void *, size_t, int);
     63extern ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
    6464extern int getsockopt(int, int, int, void *, size_t *);
    6565extern int setsockopt(int, int, int, const void *, size_t);
Note: See TracChangeset for help on using the changeset viewer.