NNTP65/POP65: Minor cleanup of error handling code.

This commit is contained in:
Bobbi Webber-Manners 2020-09-13 17:40:56 -04:00
parent 1f5f193657
commit 5c855c825e
2 changed files with 24 additions and 7 deletions

View File

@ -232,7 +232,7 @@ bool w5100_tcp_send_recv(char* sendbuf, char* recvbuf, size_t length,
written = fwrite(recvbuf + 4, 1, len, fp);
if (written != len) {
printf("Write error");
error_exit();
return false;
}
// Copy 4 bytes of overlap
@ -265,12 +265,21 @@ bool w5100_tcp_send_recv(char* sendbuf, char* recvbuf, size_t length,
continue;
}
if (rcv == 0) {
if (strncmp(sendbuf, "QUIT\r\n", 6) == 0)
return true; // This can happen on QUIT. It's okay.
else {
printf("Something bad\n");
return false;
}
}
if (rcv > length - len)
rcv = length - len;
if (rcv == 0) {
printf("Buffer overflow\n"); // Should never happen
error_exit();
printf("Buffer overflow\n");
return false;
}
{

View File

@ -227,7 +227,7 @@ bool w5100_tcp_send_recv(char* sendbuf, char* recvbuf, size_t length,
if (written != len) {
printf("Write error");
fclose(fp);
error_exit();
return false;
}
// Copy 4 bytes of overlap
@ -260,13 +260,21 @@ bool w5100_tcp_send_recv(char* sendbuf, char* recvbuf, size_t length,
continue;
}
if (rcv == 0) {
if (strncmp(sendbuf, "QUIT\r\n", 6) == 0)
return true; // This can happen on QUIT. It's okay.
else {
printf("Something bad\n");
return false;
}
}
if (rcv > length - len)
rcv = length - len;
if (rcv == 0) {
return true; // This can happen on the final QUIT
// printf("Buffer overflow\n"); // Should never happen
// error_exit();
printf("Buffer overflow\n");
return false;
}
{