mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Move psock check from [get|set]sockopt to psock_[get|set]sockopt
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/compiler.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||||
|
|
||||||
|
if (psock == NULL || psock->s_crefs <= 0)
|
||||||
|
{
|
||||||
|
return -EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NET_USRSOCK
|
#ifdef CONFIG_NET_USRSOCK
|
||||||
if (psock->s_type == SOCK_USRSOCK_TYPE)
|
if (psock->s_type == SOCK_USRSOCK_TYPE)
|
||||||
{
|
{
|
||||||
@@ -410,14 +417,8 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Get the underlying socket structure */
|
/* Get the underlying socket structure */
|
||||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
|
||||||
|
|
||||||
psock = sockfd_socket(sockfd);
|
psock = sockfd_socket(sockfd);
|
||||||
if (!psock || psock->s_crefs <= 0)
|
|
||||||
{
|
|
||||||
set_errno(EBADF);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Then let psock_getsockopt() do all of the work */
|
/* Then let psock_getsockopt() do all of the work */
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,13 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||||
|
|
||||||
|
if (psock == NULL || psock->s_crefs <= 0)
|
||||||
|
{
|
||||||
|
return -EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NET_USRSOCK
|
#ifdef CONFIG_NET_USRSOCK
|
||||||
if (psock->s_type == SOCK_USRSOCK_TYPE)
|
if (psock->s_type == SOCK_USRSOCK_TYPE)
|
||||||
{
|
{
|
||||||
@@ -450,14 +457,8 @@ int setsockopt(int sockfd, int level, int option, const void *value, socklen_t v
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Get the underlying socket structure */
|
/* Get the underlying socket structure */
|
||||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
|
||||||
|
|
||||||
psock = sockfd_socket(sockfd);
|
psock = sockfd_socket(sockfd);
|
||||||
if (!psock || psock->s_crefs <= 0)
|
|
||||||
{
|
|
||||||
set_errno(EBADF);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Then let psock_setockopt() do all of the work */
|
/* Then let psock_setockopt() do all of the work */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user