You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2020/06/12 12:22:52 UTC

[incubator-nuttx-apps] branch master updated: webclient: Fix errno in case of recv failure

This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 83324b6  webclient: Fix errno in case of recv failure
83324b6 is described below

commit 83324b68f95319180f0900d6d10314ded7c93c38
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Wed Jun 10 10:50:56 2020 +0900

    webclient: Fix errno in case of recv failure
    
    When recv() failed, the current code assumes the return value
    of recv() is a negative errno. It's wrong. Actually the return value
    in case of error is -1. The wrong assumption ends up with reporting
    EPERM, as EPERM happens to be -(-1).
    
    This commit changes the code to leave the errno set by the failed
    recv() as it is. It should be fine as wget_base() has the same
    error returning convention as recv(). That is, return -1 (ERROR)
    and set errno in the case of failure.
    
    NOTE: the close() after the errout label can also fail and overwrite
    the errno. I don't feel it's a big problem as wget_base() doesn't have
    any promise about which error should be reported.
---
 netutils/webclient/webclient.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c
index 24430de..675ce78 100644
--- a/netutils/webclient/webclient.c
+++ b/netutils/webclient/webclient.c
@@ -678,8 +678,7 @@ static int wget_base(FAR const char *url, FAR char *buffer, int buflen,
           if (ws->datend < 0)
             {
               nerr("ERROR: recv failed: %d\n", errno);
-              ret = ws->datend;
-              goto errout_with_errno;
+              goto errout;
             }
           else if (ws->datend == 0)
             {