net/udp: Remove an unused variable warning. Add some comments.

This commit is contained in:
Gregory Nutt 2018-04-27 18:26:38 -06:00
parent 5e7fe7b881
commit efed1b6aa1
5 changed files with 30 additions and 13 deletions

View File

@ -54,7 +54,7 @@ endif
ifneq ($(CONFIG_DISABLE_POLL),y)
ifeq ($(CONFIG_NET_TCP_READAHEAD),y)
NET_CSRCS += tcp_netpoll.c
SOCK_CSRCS += tcp_netpoll.c
endif
endif

View File

@ -40,7 +40,7 @@ ifneq ($(CONFIG_NET_UDP_NO_STACK),y)
# Socket layer
NET_CSRCS += udp_psock_send.c
SOCK_CSRCS += udp_psock_send.c
ifeq ($(CONFIG_NET_UDP_WRITE_BUFFERS),y)
SOCK_CSRCS += udp_psock_sendto_buffered.c
@ -50,7 +50,7 @@ endif
ifneq ($(CONFIG_DISABLE_POLL),y)
ifeq ($(CONFIG_NET_UDP_READAHEAD),y)
NET_CSRCS += udp_netpoll.c
SOCK_CSRCS += udp_netpoll.c
endif
endif

View File

@ -40,7 +40,6 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
@ -64,24 +63,26 @@
ssize_t psock_udp_send(FAR struct socket *psock, FAR const void *buf,
size_t len)
{
FAR struct udp_conn_s *conn;
DEBUGASSERT(psock != NULL && psock->s_crefs > 0);
DEBUGASSERT(psock != NULL && psock->s_crefs > 0 && psock->s_conn != NULL);
DEBUGASSERT(psock->s_type == SOCK_DGRAM);
conn = (FAR struct udp_conn_s *)psock->s_conn;
DEBUGASSERT(conn);
/* Was the UDP socket connected via connect()? */
/* Was the UDP socket connected via connect()?
* REVISIT: This same test is performed in psock_udp_sendto() where
* -EDESTADDRREQ is returned. There is a fine distinction in the
* meaning of the reported errors that I am not sure I have correct.
*/
if (!_SS_ISCONNECTED(psock->s_flags))
{
/* No, then it is not legal to call send() with this socket. */
/* No, then it is not legal to call send() with this socket.
* ENOTCONN - The socket is not connected or otherwise has not had
* the peer pre-specified.
*/
return -ENOTCONN;
}
/* Yes, then let psock_sendto to the work */
/* Let psock_sendto() do all of the work work */
return psock_udp_sendto(psock, buf, len, 0, NULL, 0);
}

View File

@ -627,6 +627,10 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
if (to != NULL && _SS_ISCONNECTED(psock->s_flags))
{
/* EISCONN - A destination address was specified and the socket is
* already connected.
*/
return -EISCONN;
}
@ -636,6 +640,10 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
else if (to == NULL && !_SS_ISCONNECTED(psock->s_flags))
{
/* EDESTADDRREQ - The socket is not connection-mode and no peer
* address is set.
*/
return -EDESTADDRREQ;
}

View File

@ -332,6 +332,10 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
if (to != NULL && _SS_ISCONNECTED(psock->s_flags))
{
/* EISCONN - A destination address was specified and the socket is
* already connected.
*/
return -EISCONN;
}
@ -341,6 +345,10 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
else if (to == NULL && !_SS_ISCONNECTED(psock->s_flags))
{
/* EDESTADDRREQ - The socket is not connection-mode and no peer\
* address is set.
*/
return -EDESTADDRREQ;
}