net/: Versions of psock_send() and pock_sendto() should not set errno. That is taken care of at a higher level in the send()/sendto() implementation as appropriate.
This commit is contained in:
parent
6c5f254a5b
commit
054b147114
@ -395,8 +395,8 @@ void ieee802154_poll(FAR struct net_driver_s *dev,
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On error,
|
||||
* -1 is returned, and errno is set appropriately. See sendto()
|
||||
* for the complete list of return values.
|
||||
* a negated errno value is retruend. See sendto() for the complete list
|
||||
* of return values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -427,8 +427,8 @@ errout:
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On error,
|
||||
* -1 is returned, and errno is set appropriately. See sendto()
|
||||
* for the complete list of return values.
|
||||
* a negated errno value is retruend. See sendto() for the complete list
|
||||
* of return values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -440,15 +440,13 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
FAR struct radio_driver_s *radio;
|
||||
FAR struct ieee802154_conn_s *conn;
|
||||
struct ieee802154_sendto_s state;
|
||||
int errcode;
|
||||
int ret = OK;
|
||||
|
||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||
|
||||
if (psock == NULL || psock->s_crefs <= 0)
|
||||
{
|
||||
errcode = EBADF;
|
||||
goto errout;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
|
||||
@ -460,8 +458,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
|
||||
if (tolen < sizeof(struct ieee802154_saddr_s))
|
||||
{
|
||||
errcode = EDESTADDRREQ;
|
||||
goto errout;
|
||||
return -EDESTADDRREQ;
|
||||
}
|
||||
|
||||
/* Get the device driver that will service this transfer */
|
||||
@ -469,8 +466,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
radio = ieee802154_find_device(conn, &conn->laddr);
|
||||
if (radio == NULL)
|
||||
{
|
||||
errcode = ENODEV;
|
||||
goto errout;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Set the socket state to sending */
|
||||
@ -548,8 +544,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
|
||||
if (state.is_sent < 0)
|
||||
{
|
||||
errcode = state.is_sent;
|
||||
goto errout;
|
||||
return state.is_sent;
|
||||
}
|
||||
|
||||
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
||||
@ -558,17 +553,12 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return the number of bytes actually sent */
|
||||
|
||||
return state.is_sent;
|
||||
|
||||
errout:
|
||||
set_errno(errcode);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
|
@ -292,46 +292,8 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn);
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On error,
|
||||
* -1 is returned, and errno is set appropriately:
|
||||
*
|
||||
* EAGAIN or EWOULDBLOCK
|
||||
* The socket is marked non-blocking and the requested operation
|
||||
* would block.
|
||||
* EBADF
|
||||
* An invalid descriptor was specified.
|
||||
* ECONNRESET
|
||||
* Connection reset by peer.
|
||||
* EDESTADDRREQ
|
||||
* The socket is not connection-mode, and no peer address is set.
|
||||
* EFAULT
|
||||
* An invalid user space address was specified for a parameter.
|
||||
* EINTR
|
||||
* A signal occurred before any data was transmitted.
|
||||
* EINVAL
|
||||
* Invalid argument passed.
|
||||
* EISCONN
|
||||
* The connection-mode socket was connected already but a recipient
|
||||
* was specified. (Now either this error is returned, or the recipient
|
||||
* specification is ignored.)
|
||||
* EMSGSIZE
|
||||
* The socket type requires that message be sent atomically, and the
|
||||
* size of the message to be sent made this impossible.
|
||||
* ENOBUFS
|
||||
* The output queue for a network interface was full. This generally
|
||||
* indicates that the interface has stopped sending, but may be
|
||||
* caused by transient congestion.
|
||||
* ENOMEM
|
||||
* No memory available.
|
||||
* ENOTCONN
|
||||
* The socket is not connected, and no target has been given.
|
||||
* ENOTSOCK
|
||||
* The argument s is not a socket.
|
||||
* EPIPE
|
||||
* The local end has been shut down on a connection oriented socket.
|
||||
* In this case the process will also receive a SIGPIPE unless
|
||||
* MSG_NOSIGNAL is set.
|
||||
*
|
||||
* Assumptions:
|
||||
* a negated errno value is retruend. See send() for the complete list
|
||||
* of return values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* net/pkt/pkt_send.c
|
||||
*
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -165,46 +164,8 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On error,
|
||||
* -1 is returned, and errno is set appropriately:
|
||||
*
|
||||
* EAGAIN or EWOULDBLOCK
|
||||
* The socket is marked non-blocking and the requested operation
|
||||
* would block.
|
||||
* EBADF
|
||||
* An invalid descriptor was specified.
|
||||
* ECONNRESET
|
||||
* Connection reset by peer.
|
||||
* EDESTADDRREQ
|
||||
* The socket is not connection-mode, and no peer address is set.
|
||||
* EFAULT
|
||||
* An invalid user space address was specified for a parameter.
|
||||
* EINTR
|
||||
* A signal occurred before any data was transmitted.
|
||||
* EINVAL
|
||||
* Invalid argument passed.
|
||||
* EISCONN
|
||||
* The connection-mode socket was connected already but a recipient
|
||||
* was specified. (Now either this error is returned, or the recipient
|
||||
* specification is ignored.)
|
||||
* EMSGSIZE
|
||||
* The socket type requires that message be sent atomically, and the
|
||||
* size of the message to be sent made this impossible.
|
||||
* ENOBUFS
|
||||
* The output queue for a network interface was full. This generally
|
||||
* indicates that the interface has stopped sending, but may be
|
||||
* caused by transient congestion.
|
||||
* ENOMEM
|
||||
* No memory available.
|
||||
* ENOTCONN
|
||||
* The socket is not connected, and no target has been given.
|
||||
* ENOTSOCK
|
||||
* The argument s is not a socket.
|
||||
* EPIPE
|
||||
* The local end has been shut down on a connection oriented socket.
|
||||
* In this case the process will also receive a SIGPIPE unless
|
||||
* MSG_NOSIGNAL is set.
|
||||
*
|
||||
* Assumptions:
|
||||
* a negated errno value is retruend. See send() for the complete list
|
||||
* of return values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -213,15 +174,13 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
struct send_s state;
|
||||
int errcode;
|
||||
int ret = OK;
|
||||
|
||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||
|
||||
if (!psock || psock->s_crefs <= 0)
|
||||
{
|
||||
errcode = EBADF;
|
||||
goto errout;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
/* Get the device driver that will service this transfer */
|
||||
@ -229,8 +188,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
||||
dev = pkt_find_device((FAR struct pkt_conn_s *)psock->s_conn);
|
||||
if (dev == NULL)
|
||||
{
|
||||
errcode = ENODEV;
|
||||
goto errout;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Set the socket state to sending */
|
||||
@ -304,8 +262,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
||||
|
||||
if (state.snd_sent < 0)
|
||||
{
|
||||
errcode = state.snd_sent;
|
||||
goto errout;
|
||||
return state.snd_sent;
|
||||
}
|
||||
|
||||
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
||||
@ -314,17 +271,12 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return the number of bytes actually sent */
|
||||
|
||||
return state.snd_sent;
|
||||
|
||||
errout:
|
||||
set_errno(errcode);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_PKT */
|
||||
|
Loading…
Reference in New Issue
Block a user