xiaoxiang781216 commented on code in PR #3117:
URL: https://github.com/apache/nuttx-apps/pull/3117#discussion_r2180466383


##########
system/nxplayer/nxplayer.c:
##########
@@ -221,18 +220,35 @@ static int _open_with_http(const char *fullurl)
 
   FAR struct hostent *he;
   he = gethostbyname(hostname);
+  if (!he)
+    {
+      close(s);
+      return -ENETUNREACH; /* DNS resolution failed */
+    }
 
   memcpy(&server.sin_addr.s_addr,
          he->h_addr, sizeof(in_addr_t));
-
   n = connect(s,
               (struct sockaddr *)&server,
               sizeof(struct sockaddr_in));
-
   if (-1 == n)
     {
+      int err = errno;
       close(s);
-      return -1;
+      switch (err)
+        {
+          case ETIMEDOUT:

Review Comment:
   why not return -err



##########
system/nxplayer/nxplayer.c:
##########
@@ -250,8 +266,25 @@ static int _open_with_http(const char *fullurl)
 
   if (200 != n)
     {
+      int err = errno;
       close(s);
-      return -1;
+      switch (err)
+        {
+          case 401:

Review Comment:
   why do you think errno contain 401/403?



##########
system/nxplayer/nxplayer.c:
##########
@@ -1809,11 +1842,15 @@ static int nxplayer_playinternal(FAR struct nxplayer_s 
*pplayer,
   /* Test that the specified file exists */
 
 #ifdef CONFIG_NXPLAYER_HTTP_STREAMING_SUPPORT
-  if ((pplayer->fd = _open_with_http(pfilename)) == -1)
+  pplayer->fd = _open_with_http(pfilename);
+  if (pplayer->fd < 0)
 #else
-  if ((pplayer->fd = open(pfilename, O_RDONLY)) == -1)
+  pplayer->fd = open(pfilename, O_RDONLY);
+  if (pplayer->fd == -1)
 #endif
     {
+      int err = errno;

Review Comment:
   why catch 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-unsubscr...@nuttx.apache.org

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

Reply via email to