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.
This commit is contained in:
parent
1d4dc43e73
commit
83324b68f9
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user