Skip to content

Commit

Permalink
Replace set_errno to _SO_SETERRNO
Browse files Browse the repository at this point in the history
Missed in a previous commit
  • Loading branch information
xiaoxiang781216 authored and gregory-nutt committed Jan 31, 2020
1 parent 6e6c670 commit cf2ddbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
16 changes: 8 additions & 8 deletions net/socket/getsockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
return -EINVAL;
}

/* Verify that the sockfd corresponds to valid, allocated socket */

if (psock == NULL || psock->s_crefs <= 0)
{
return -EBADF;
}

#ifdef CONFIG_NET_USRSOCK
if (psock->s_type == SOCK_USRSOCK_TYPE)
{
Expand Down Expand Up @@ -342,6 +335,13 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
{
int ret;

/* Verify that the sockfd corresponds to valid, allocated socket */

if (psock == NULL || psock->s_crefs <= 0)
{
return -EBADF;
}

/* Handle retrieval of the socket option according to the level at which
* option should be applied.
*/
Expand Down Expand Up @@ -436,7 +436,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
ret = psock_getsockopt(psock, level, option, value, value_len);
if (ret < 0)
{
set_errno(-ret);
_SO_SETERRNO(psock, -ret);
return ERROR;
}

Expand Down
20 changes: 8 additions & 12 deletions net/socket/setsockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
return -EINVAL;
}

/* Verify that the sockfd corresponds to valid, allocated socket */

if (psock == NULL || psock->s_crefs <= 0)
{
return -EBADF;
}

#ifdef CONFIG_NET_USRSOCK
if (psock->s_type == SOCK_USRSOCK_TYPE)
{
Expand Down Expand Up @@ -362,6 +355,13 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
{
int ret;

/* Verify that the sockfd corresponds to valid, allocated socket */

if (psock == NULL || psock->s_crefs <= 0)
{
return -EBADF;
}

/* Handle setting of the socket option according to the level at which
* option should be applied.
*/
Expand All @@ -384,10 +384,6 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
break;
#endif

/* These levels are defined in sys/socket.h, but are not yet
* implemented.
*/

#ifdef CONFIG_NET_IPv4
case SOL_IP: /* TCP protocol socket options (see include/netinet/in.h) */
ret = ipv4_setsockopt(psock, option, value, value_len);
Expand Down Expand Up @@ -474,7 +470,7 @@ int setsockopt(int sockfd, int level, int option, const void *value,
ret = psock_setsockopt(psock, level, option, value, value_len);
if (ret < 0)
{
set_errno(-ret);
_SO_SETERRNO(psock, -ret);
return ERROR;
}

Expand Down

0 comments on commit cf2ddbb

Please sign in to comment.