You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/28 15:56:14 UTC

[GitHub] [incubator-nuttx] zhhyu7 opened a new pull request, #7462: socket: Separation error code EBADF and ENOTSOCK

zhhyu7 opened a new pull request, #7462:
URL: https://github.com/apache/incubator-nuttx/pull/7462

   Signed-off-by: zhanghongyu <zh...@xiaomi.com>
   
   ## Summary
   user space can close fd when errno is ENOTSOCK.
   ## Impact
   
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko merged pull request #7462: socket: Separation error code EBADF and ENOTSOCK

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #7462:
URL: https://github.com/apache/incubator-nuttx/pull/7462


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7462: socket: Separation error code EBADF and ENOTSOCK

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7462:
URL: https://github.com/apache/incubator-nuttx/pull/7462#discussion_r1008377828


##########
fs/socket/socket.c:
##########
@@ -192,16 +196,20 @@ FAR struct socket *file_socket(FAR struct file *filep)
   return NULL;
 }
 
-FAR struct socket *sockfd_socket(int sockfd)
+int sockfd_socket(int sockfd, FAR struct socket **socketp)
 {
   FAR struct file *filep;
 
+  *socketp = NULL;

Review Comment:
   I'm not sure if this is needed. If we decide to keep it, then let's place it before `return -EBADF;`



##########
fs/socket/socket.c:
##########
@@ -192,16 +196,20 @@ FAR struct socket *file_socket(FAR struct file *filep)
   return NULL;
 }
 
-FAR struct socket *sockfd_socket(int sockfd)
+int sockfd_socket(int sockfd, FAR struct socket **socketp)
 {
   FAR struct file *filep;
 
+  *socketp = NULL;
+
   if (fs_getfilep(sockfd, &filep) < 0)
     {
-      return NULL;
+      return -EBADF;
     }
 
-  return file_socket(filep);
+  *socketp = file_socket(filep);
+
+  return *socketp != NULL ? OK: -ENOTSOCK;

Review Comment:
   ```suggestion
     return *socketp != NULL ? OK : -ENOTSOCK;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org