From 05d40eeeff9b04e328bc763ae02c2accd635d2e7 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 27 Oct 2022 02:33:51 +0800 Subject: [PATCH] net: Remove the unused nx_recv[from] to prefer psock_recv[from] for kernel Signed-off-by: Xiang Xiao --- include/nuttx/net/net.h | 68 ----------------------------------------- net/socket/recvfrom.c | 54 +++++--------------------------- 2 files changed, 8 insertions(+), 114 deletions(-) diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index 4bf0e5a5545..9306e1e6b64 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -43,38 +43,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Most internal network OS interfaces are not available in the user space in - * PROTECTED and KERNEL builds. In that context, the corresponding - * application network interfaces must be used. The differences between the - * two sets of interfaces are: The internal OS interfaces (1) do not cause - * cancellation points and (2) they do not modify the errno variable. - * - * This is only important when compiling libraries (libc or libnx) that are - * used both by the OS (libkc.a and libknx.a) or by the applications - * (libc.a and libnx.a). In that case, the correct interface must be - * used for the build context. - * - * REVISIT: In the flat build, the same functions must be used both by - * the OS and by applications. We have to use the normal user functions - * in this case or we will fail to set the errno or fail to create the - * cancellation point. - * - * The interfaces accept(), read(), recv(), recvfrom(), write(), send(), - * sendto() are all cancellation points. - * - * REVISIT: These cancellation points are an issue and may cause - * violations: It use of these internally will cause the calling function - * to become a cancellation points! - */ - -#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) -# define _NX_RECV(s,b,l,f) nx_recv(s,b,l,f) -# define _NX_RECVFROM(s,b,l,f,a,n) nx_recvfrom(s,b,l,f,a,n) -#else -# define _NX_RECV(s,b,l,f) recv(s,b,l,f) -# define _NX_RECVFROM(s,b,l,f,a,n) recvfrom(s,b,l,f,a,n) -#endif - /* Capabilities of a socket */ #define SOCKCAP_NONBLOCKING (1 << 0) /* Bit 0: Socket supports non-blocking @@ -1032,42 +1000,6 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, #define psock_recv(psock,buf,len,flags) \ psock_recvfrom(psock,buf,len,flags,NULL,0) -/**************************************************************************** - * Name: nx_recvfrom - * - * Description: - * nx_recvfrom() receives messages from a socket, and may be used to - * receive data on a socket whether or not it is connection-oriented. - * This is an internal OS interface. It is functionally equivalent to - * recvfrom() except that: - * - * - It is not a cancellation point, and - * - It does not modify the errno variable. - * - * Input Parameters: - * sockfd Socket descriptor of socket - * buf Buffer to receive data - * len Length of buffer - * flags Receive flags - * from Address of source (may be NULL) - * fromlen The length of the address structure - * - * Returned Value: - * On success, returns the number of characters received. If no data is - * available to be received and the peer has performed an orderly shutdown, - * nx_recvfrom() will return 0. Otherwise, on any failure, a negated errno - * value is returned (see comments with recvfrom() for a list of - * appropriate errno values). - * - ****************************************************************************/ - -ssize_t nx_recvfrom(int sockfd, FAR void *buf, size_t len, int flags, - FAR struct sockaddr *from, FAR socklen_t *fromlen); - -/* Internal version os recv */ - -#define nx_recv(psock,buf,len,flags) nx_recvfrom(psock,buf,len,flags,NULL,0) - /**************************************************************************** * Name: psock_getsockopt * diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index 75f3175683c..d3e3f709044 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -96,49 +96,6 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, return ret; } -/**************************************************************************** - * Name: nx_recvfrom - * - * Description: - * nx_recvfrom() receives messages from a socket, and may be used to - * receive data on a socket whether or not it is connection-oriented. - * This is an internal OS interface. It is functionally equivalent to - * recvfrom() except that: - * - * - It is not a cancellation point, and - * - It does not modify the errno variable. - * - * Input Parameters: - * sockfd Socket descriptor of socket - * buf Buffer to receive data - * len Length of buffer - * flags Receive flags - * from Address of source (may be NULL) - * fromlen The length of the address structure - * - * Returned Value: - * On success, returns the number of characters received. If no data is - * available to be received and the peer has performed an orderly shutdown, - * nx_recvfrom() will return 0. Otherwise, on any failure, a negated errno - * value is returned (see comments with recvfrom() for a list of - * appropriate errno values). - * - ****************************************************************************/ - -ssize_t nx_recvfrom(int sockfd, FAR void *buf, size_t len, int flags, - FAR struct sockaddr *from, FAR socklen_t *fromlen) -{ - FAR struct socket *psock; - - /* Get the underlying socket structure */ - - psock = sockfd_socket(sockfd); - - /* Then let psock_recvfrom() do all of the work */ - - return psock_recvfrom(psock, buf, len, flags, from, fromlen); -} - /**************************************************************************** * Name: recvfrom * @@ -193,18 +150,23 @@ ssize_t nx_recvfrom(int sockfd, FAR void *buf, size_t len, int flags, ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, FAR socklen_t *fromlen) { + FAR struct socket *psock; ssize_t ret; /* recvfrom() is a cancellation point */ enter_cancellation_point(); - /* Let psock_recvfrom() do all of the work */ + /* Get the underlying socket structure */ - ret = nx_recvfrom(sockfd, buf, len, flags, from, fromlen); + psock = sockfd_socket(sockfd); + + /* Then let psock_recvfrom() do all of the work */ + + ret = psock_recvfrom(psock, buf, len, flags, from, fromlen); if (ret < 0) { - _SO_SETERRNO(sockfd_socket(sockfd), -ret); + _SO_SETERRNO(psock, -ret); ret = ERROR; }