wininet: Avoid testing errno when it isn't set. Simplify NETCON_getNextLine a bit.

This commit is contained in:
Alexandre Julliard 2008-08-26 20:40:09 +02:00
parent 5f727cb2af
commit 9bded7bb2a

View File

@ -634,8 +634,8 @@ BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPD
if (!connection->useSSL) if (!connection->useSSL)
{ {
struct pollfd pfd; struct pollfd pfd;
BOOL bSuccess = FALSE;
DWORD nRecv = 0; DWORD nRecv = 0;
int ret;
pfd.fd = connection->socketFD; pfd.fd = connection->socketFD;
pfd.events = POLLIN; pfd.events = POLLIN;
@ -644,16 +644,18 @@ BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPD
{ {
if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0) if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
{ {
if (recv(connection->socketFD, &lpszBuffer[nRecv], 1, 0) <= 0) if ((ret = recv(connection->socketFD, &lpszBuffer[nRecv], 1, 0)) <= 0)
{ {
INTERNET_SetLastError(sock_get_error(errno)); if (ret == -1) INTERNET_SetLastError(sock_get_error(errno));
goto lend; break;
} }
if (lpszBuffer[nRecv] == '\n') if (lpszBuffer[nRecv] == '\n')
{ {
bSuccess = TRUE; lpszBuffer[nRecv++] = '\0';
break; *dwBuffer = nRecv;
TRACE(":%u %s\n", nRecv, lpszBuffer);
return TRUE;
} }
if (lpszBuffer[nRecv] != '\r') if (lpszBuffer[nRecv] != '\r')
nRecv++; nRecv++;
@ -661,22 +663,9 @@ BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPD
else else
{ {
INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT); INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
goto lend; break;
} }
} }
lend: /* FIXME: don't use labels */
if (bSuccess)
{
lpszBuffer[nRecv++] = '\0';
*dwBuffer = nRecv;
TRACE(":%u %s\n", nRecv, lpszBuffer);
return TRUE;
}
else
{
return FALSE;
}
} }
else else
{ {
@ -714,11 +703,9 @@ BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPD
TRACE("_SSL:%u %s\n", nRecv, lpszBuffer); TRACE("_SSL:%u %s\n", nRecv, lpszBuffer);
return TRUE; return TRUE;
} }
return FALSE;
#else
return FALSE;
#endif #endif
} }
return FALSE;
} }