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/11/24 07:47:49 UTC

[GitHub] [incubator-nuttx] anchao opened a new pull request, #7675: net: remove psock reference from connect

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

   ## Summary
   
   net: remove psock reference from connect
   
   Signed-off-by: chao.an <an...@xiaomi.com>
   
   ## Impact
   
   N/A
   
   ## Testing
   
   ci check


-- 
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] anchao commented on a diff in pull request #7675: net: remove psock reference from connect

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


##########
net/socket/socket.h:
##########
@@ -94,18 +94,30 @@
 /* Macro to set socket errors */
 
 #ifdef CONFIG_NET_SOCKOPTS
+#  define _SO_CONN_SETERRNO(c,e) \
+    do \
+      { \
+        (c)->s_error = (int16_t)e; \
+        set_errno(e); \
+      } \
+    while (0)
+
 #  define _SO_SETERRNO(s,e) \
     do \
       { \
         if (s != NULL && (s)->s_conn != NULL) \

Review Comment:
   Done



##########
net/socket/socket.h:
##########
@@ -94,18 +94,30 @@
 /* Macro to set socket errors */
 
 #ifdef CONFIG_NET_SOCKOPTS
+#  define _SO_CONN_SETERRNO(c,e) \
+    do \
+      { \
+        (c)->s_error = (int16_t)e; \
+        set_errno(e); \
+      } \
+    while (0)
+
 #  define _SO_SETERRNO(s,e) \
     do \
       { \
         if (s != NULL && (s)->s_conn != NULL) \
           { \
             FAR struct socket_conn_s *_conn = (s)->s_conn; \
-            _conn->s_error = (int16_t)e; \
+            _SO_CONN_SETERRNO(_conn, e); \

Review Comment:
   Done



-- 
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] xiaoxiang781216 commented on a diff in pull request #7675: net: remove psock reference from connect

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


##########
net/rpmsg/rpmsg_sockif.c:
##########
@@ -287,11 +286,11 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept,
       nxmutex_lock(&conn->recvlock);
       conn->sendsize = head->size;
 
-      if (conn->psock)
-        {
-          conn->sconn.s_flags |= _SF_CONNECTED;
-          _SO_SETERRNO(conn->psock, OK);
-        }
+      conn->sconn.s_flags |= _SF_CONNECTED;
+#ifdef CONFIG_NET_SOCKOPTS
+      conn->sconn.s_error = OK;
+#endif
+      set_errno(OK);

Review Comment:
   should we create a new patch which change the first parameter of _SO_SETERRNO  to conn?



-- 
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] xiaoxiang781216 commented on a diff in pull request #7675: net: remove psock reference from connect

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


##########
net/rpmsg/rpmsg_sockif.c:
##########
@@ -287,11 +286,11 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept,
       nxmutex_lock(&conn->recvlock);
       conn->sendsize = head->size;
 
-      if (conn->psock)
-        {
-          conn->sconn.s_flags |= _SF_CONNECTED;
-          _SO_SETERRNO(conn->psock, OK);
-        }
+      conn->sconn.s_flags |= _SF_CONNECTED;
+#ifdef CONFIG_NET_SOCKOPTS
+      conn->sconn.s_error = OK;
+#endif
+      set_errno(OK);

Review Comment:
   why call set_errno here



-- 
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] xiaoxiang781216 commented on a diff in pull request #7675: net: remove psock reference from connect

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


##########
net/tcp/tcp_monitor.c:
##########
@@ -165,10 +165,7 @@ static uint16_t tcp_monitor_event(FAR struct net_driver_s *dev,
 
           /* Clear the socket error */
 
-#ifdef CONFIG_NET_SOCKOPTS
-          conn->sconn.s_error = OK;
-#endif
-          set_errno(OK);
+          _SO_CONN_SETERRNO(&conn->sconn, OK);

Review Comment:
   _SO_CONN_SETERRNO(conn, OK);



##########
net/socket/net_sendfile.c:
##########
@@ -133,8 +133,7 @@ ssize_t psock_sendfile(FAR struct socket *psock, FAR struct file *infile,
 
   if (ret < 0)
     {
-      FAR struct socket_conn_s *conn = psock->s_conn;
-      conn->s_error = -ret;
+      _SO_CONN_SETERRNO((FAR struct socket_conn_s *)psock->s_conn, -ret);

Review Comment:
   move the cast to _SO_CONN_SETERRNO



##########
net/tcp/tcp_netpoll.c:
##########
@@ -128,10 +128,7 @@ static uint16_t tcp_poll_eventhandler(FAR struct net_driver_s *dev,
               reason = ECONNREFUSED;
             }
 
-#ifdef CONFIG_NET_SOCKOPTS
-          info->conn->sconn.s_error = reason;
-#endif
-          set_errno(reason);
+          _SO_CONN_SETERRNO(&info->conn->sconn, reason);

Review Comment:
    _SO_CONN_SETERRNO(info->conn, reason);



##########
net/socket/socket.h:
##########
@@ -94,18 +94,30 @@
 /* Macro to set socket errors */
 
 #ifdef CONFIG_NET_SOCKOPTS
+#  define _SO_CONN_SETERRNO(c,e) \
+    do \
+      { \
+        (c)->s_error = (int16_t)e; \
+        set_errno(e); \
+      } \
+    while (0)
+
 #  define _SO_SETERRNO(s,e) \
     do \
       { \
         if (s != NULL && (s)->s_conn != NULL) \
           { \
             FAR struct socket_conn_s *_conn = (s)->s_conn; \
-            _conn->s_error = (int16_t)e; \
+            _SO_CONN_SETERRNO(_conn, e); \

Review Comment:
   _SO_CONN_SETERRNO((s)->s_conn, e);
   and remove line 109



##########
net/rpmsg/rpmsg_sockif.c:
##########
@@ -287,11 +286,9 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept,
       nxmutex_lock(&conn->recvlock);
       conn->sendsize = head->size;
 
-      if (conn->psock)
-        {
-          conn->sconn.s_flags |= _SF_CONNECTED;
-          _SO_SETERRNO(conn->psock, OK);
-        }
+      conn->sconn.s_flags |= _SF_CONNECTED;
+
+      _SO_CONN_SETERRNO(&conn->sconn, OK);

Review Comment:
   _SO_CONN_SETERRNO(conn, OK);



##########
net/can/can_recvmsg.c:
##########
@@ -608,7 +606,7 @@ ssize_t can_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
     }
 #endif
 
-  state.pr_sock   = psock;
+  state.pr_conn   = conn;

Review Comment:
   remove extra space before =



##########
net/socket/socket.h:
##########
@@ -94,18 +94,30 @@
 /* Macro to set socket errors */
 
 #ifdef CONFIG_NET_SOCKOPTS
+#  define _SO_CONN_SETERRNO(c,e) \
+    do \
+      { \
+        (c)->s_error = (int16_t)e; \
+        set_errno(e); \
+      } \
+    while (0)
+
 #  define _SO_SETERRNO(s,e) \
     do \
       { \
         if (s != NULL && (s)->s_conn != NULL) \

Review Comment:
   let's move (s)->s_conn check to _SO_CONN_SETERRNO



-- 
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] anchao commented on a diff in pull request #7675: net: remove psock reference from connect

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


##########
net/rpmsg/rpmsg_sockif.c:
##########
@@ -287,11 +286,9 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept,
       nxmutex_lock(&conn->recvlock);
       conn->sendsize = head->size;
 
-      if (conn->psock)
-        {
-          conn->sconn.s_flags |= _SF_CONNECTED;
-          _SO_SETERRNO(conn->psock, OK);
-        }
+      conn->sconn.s_flags |= _SF_CONNECTED;
+
+      _SO_CONN_SETERRNO(&conn->sconn, OK);

Review Comment:
   Done



##########
net/tcp/tcp_netpoll.c:
##########
@@ -128,10 +128,7 @@ static uint16_t tcp_poll_eventhandler(FAR struct net_driver_s *dev,
               reason = ECONNREFUSED;
             }
 
-#ifdef CONFIG_NET_SOCKOPTS
-          info->conn->sconn.s_error = reason;
-#endif
-          set_errno(reason);
+          _SO_CONN_SETERRNO(&info->conn->sconn, reason);

Review Comment:
   Done



##########
net/tcp/tcp_monitor.c:
##########
@@ -165,10 +165,7 @@ static uint16_t tcp_monitor_event(FAR struct net_driver_s *dev,
 
           /* Clear the socket error */
 
-#ifdef CONFIG_NET_SOCKOPTS
-          conn->sconn.s_error = OK;
-#endif
-          set_errno(OK);
+          _SO_CONN_SETERRNO(&conn->sconn, OK);

Review Comment:
   Done



##########
net/socket/net_sendfile.c:
##########
@@ -133,8 +133,7 @@ ssize_t psock_sendfile(FAR struct socket *psock, FAR struct file *infile,
 
   if (ret < 0)
     {
-      FAR struct socket_conn_s *conn = psock->s_conn;
-      conn->s_error = -ret;
+      _SO_CONN_SETERRNO((FAR struct socket_conn_s *)psock->s_conn, -ret);

Review Comment:
   Done



-- 
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] anchao commented on a diff in pull request #7675: net: remove psock reference from connect

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


##########
net/rpmsg/rpmsg_sockif.c:
##########
@@ -287,11 +286,11 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept,
       nxmutex_lock(&conn->recvlock);
       conn->sendsize = head->size;
 
-      if (conn->psock)
-        {
-          conn->sconn.s_flags |= _SF_CONNECTED;
-          _SO_SETERRNO(conn->psock, OK);
-        }
+      conn->sconn.s_flags |= _SF_CONNECTED;
+#ifdef CONFIG_NET_SOCKOPTS
+      conn->sconn.s_error = OK;
+#endif
+      set_errno(OK);

Review Comment:
   Replace _SO_SETERRNO for equivalent, _SO_SETERRNO change the errno



-- 
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] xiaoxiang781216 merged pull request #7675: net: remove psock reference from connect

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


-- 
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