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 <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-10 16:02:57 +00:00
parent 82dbeb9736
commit 13c759bf3a
+3 -11
View File
@@ -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;