From 5846f9dbb1274ca39917fea4a8993eebeaeed2ed Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Tue, 18 Feb 2020 10:21:38 -0500 Subject: [PATCH] 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 --- libdevs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libdevs.c b/libdevs.c index bb47fb6..fa20d0b 100644 --- a/libdevs.c +++ b/libdevs.c @@ -415,7 +415,16 @@ static int read_all(int fd, char *buf, size_t count) if (rc < 0) { if (errno == EINTR) 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; } assert(rc != 0); /* We should never hit the end of the file. */