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/08/16 10:20:17 UTC

[GitHub] [incubator-nuttx-apps] Weizihan opened a new pull request, #1280: apps: Fix the bug that setsockopt didn't check return value

Weizihan opened a new pull request, #1280:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1280

   Signed-off-by: weizihan <we...@xiaomi.com>
   
   ## Summary
   netutils/webclient/webclient.c
   Fix the bug that setsockopt didn't check return value
   
   ## Impact
   webclient.c check return value one by one
   
   ## Testing
   passed vela CI
   


-- 
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-apps] xiaoxiang781216 commented on pull request #1280: apps: Fix the bug that setsockopt didn't check return value

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #1280:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1280#issuecomment-1216512575

   @Weizihan please fix the warning:
   https://github.com/apache/incubator-nuttx-apps/runs/7855724603?check_suite_focus=true


-- 
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-apps] pkarashchenko commented on a diff in pull request #1280: apps: Fix the bug that setsockopt didn't check return value

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


##########
netutils/webclient/webclient.c:
##########
@@ -1417,10 +1417,25 @@ int webclient_perform(FAR struct webclient_context *ctx)
                   tv.tv_sec  = ctx->timeout_sec;
                   tv.tv_usec = 0;
 
-                  setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
+                  /* Check return value one by one */
+
+                  ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
                              (FAR const void *)&tv, sizeof(struct timeval));

Review Comment:
   ```suggestion
                     ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
                                      (FAR const void *)&tv, sizeof(struct timeval));
   ```



##########
netutils/webclient/webclient.c:
##########
@@ -1417,10 +1417,25 @@ int webclient_perform(FAR struct webclient_context *ctx)
                   tv.tv_sec  = ctx->timeout_sec;
                   tv.tv_usec = 0;
 
-                  setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
+                  /* Check return value one by one */
+
+                  ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
                              (FAR const void *)&tv, sizeof(struct timeval));
-                  setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
+                  if (ret != 0)
+                    {
+                      ret = -errno;
+                      nerr("ERROR: setsockopt failed: %d\n", ret);
+                      goto errout_with_errno;
+                    }
+
+                  ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
                              (FAR const void *)&tv, sizeof(struct timeval));

Review Comment:
   ```suggestion
                     ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
                                      (FAR const void *)&tv, sizeof(struct timeval));
   ```



-- 
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-apps] Weizihan merged pull request #1280: apps: Fix the bug that setsockopt didn't check return value

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


-- 
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-apps] Weizihan commented on a diff in pull request #1280: apps: Fix the bug that setsockopt didn't check return value

Posted by GitBox <gi...@apache.org>.
Weizihan commented on code in PR #1280:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1280#discussion_r947432878


##########
netutils/webclient/webclient.c:
##########
@@ -1417,10 +1417,25 @@ int webclient_perform(FAR struct webclient_context *ctx)
                   tv.tv_sec  = ctx->timeout_sec;
                   tv.tv_usec = 0;
 
-                  setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
+                  /* Check return value one by one */
+
+                  ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
                              (FAR const void *)&tv, sizeof(struct timeval));
-                  setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
+                  if (ret != 0)
+                    {
+                      ret = -errno;
+                      nerr("ERROR: setsockopt failed: %d\n", ret);
+                      goto errout_with_errno;
+                    }
+
+                  ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
                              (FAR const void *)&tv, sizeof(struct timeval));

Review Comment:
   ok



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