Squashed commit of the following:

psock_close() and net_close() are internal OS functions and should not set the errno variable.

    psock_ioctl() and netdev_ioctl() are internal OS functions and should not set the errno variable.

    net_dupsd() and net_dupsd2() are internal OS functions and should not set the errno variable.

    net/ and fs/: net_vfcntl(), file_fcntl(), file_dup(), and file_dup2() are all internal OS interfaces and should not modify the errno value.
This commit is contained in:
Gregory Nutt
2017-09-30 10:41:21 -06:00
parent 2c2aa94b7d
commit e4dd33280d
18 changed files with 251 additions and 180 deletions
+14 -11
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* net/socket/net_dupsd.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,10 @@
* of socket file descriptors. If file descriptors are not implemented,
* then this function IS dup().
*
* Returned Value:
* On success, returns the number of characters sent. On any error,
* a negated errno value is returned:.
*
****************************************************************************/
int net_dupsd(int sockfd, int minsd)
@@ -68,7 +72,6 @@ int net_dupsd(int sockfd, int minsd)
FAR struct socket *psock1;
FAR struct socket *psock2;
int sockfd2;
int errcode;
int ret;
/* Make sure that the minimum socket descriptor is within the legal range.
@@ -99,7 +102,7 @@ int net_dupsd(int sockfd, int minsd)
if (!psock1 || psock1->s_crefs <= 0)
{
errcode = EBADF;
ret = -EBADF;
goto errout;
}
@@ -108,7 +111,7 @@ int net_dupsd(int sockfd, int minsd)
sockfd2 = sockfd_allocate(minsd);
if (sockfd2 < 0)
{
errcode = ENFILE;
ret = -ENFILE;
goto errout;
}
@@ -117,8 +120,8 @@ int net_dupsd(int sockfd, int minsd)
psock2 = sockfd_socket(sockfd2);
if (!psock2)
{
errcode = ENOSYS; /* should not happen */
goto errout;
ret = -ENOSYS; /* Should not happen */
goto errout_with_sockfd;
}
/* Duplicate the socket state */
@@ -126,18 +129,18 @@ int net_dupsd(int sockfd, int minsd)
ret = net_clone(psock1, psock2);
if (ret < 0)
{
errcode = -ret;
goto errout;
goto errout_with_sockfd;
}
sched_unlock();
return sockfd2;
errout_with_sockfd:
sockfd_release(sockfd2);
errout:
sched_unlock();
set_errno(errcode);
return ERROR;
return ret;
}
#endif /* defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 */