f3probe: report unexpected error codes in read_all()

No unexpected error code should happen in read_all(), but,
if it does, f3probe will report them before aborting.

This patch address the request of user @vi at the following comment:
https://github.com/AltraMayor/f3/issues/82#issuecomment-585829975
This commit is contained in:
Michel Machado 2020-02-18 10:21:38 -05:00
parent 3c19d21859
commit 5846f9dbb1

View File

@ -415,7 +415,16 @@ static int read_all(int fd, char *buf, size_t count)
if (rc < 0) { if (rc < 0) {
if (errno == EINTR) if (errno == EINTR)
continue; continue;
assert(errno == EIO || errno == ENODATA); if (errno == EIO || errno == ENODATA) {
/* These errors are "expected",
* so ignore them.
*/
} else {
/* Execution should not come here. */
err(errno,
"%s(): unexpected error code from read(2) = %i",
__func__, errno);
}
return - errno; return - errno;
} }
assert(rc != 0); /* We should never hit the end of the file. */ assert(rc != 0); /* We should never hit the end of the file. */