From 13c759bf3ac586ee8142353f5efbc48a177b29ee Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 10 Mar 2026 16:02:57 +0000 Subject: util/nvmutil: don't reset errno in rw_file_exact reset it in callers instead. this means that the main function is more generalised. we know by the time we exit that there is no error. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 9e0a1e10..010349e9 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1015,6 +1015,7 @@ rhex(void) n = sizeof(rnum); if (rw_file_exact(urandom_fd, rnum, n, 0, LESEN) == -1) err(errno, "Randomisation failed"); + errno = 0; } return (uint16_t)(rnum[--n] & 0xf); @@ -1323,6 +1324,8 @@ rw_gbe_file_part(size_t p, int rw_type, rw_type) == -1) err(errno, "%s: %s: part %lu", fname, rw_type_str, (unsigned long)p); + + errno = 0; } /* @@ -1440,17 +1443,6 @@ rw_file_exact(int fd, uint8_t *mem, size_t len, rc += (size_t)rval; continue; } - if (errno == EINTR) { - /* - * EINTR is not fatal, because we - * eventually return. We rely on - * errno for general error state - * after return from rw_file_exact, - * so we don't want a false error. - */ - errno = 0; - continue; - } set_err(EIO); return -1; -- cgit v1.2.1