util/nvmutil: tidy up prw()

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-14 00:40:00 +00:00
parent 69ff774ad3
commit b89e965ed7

View File

@@ -1681,7 +1681,7 @@ prw(int fd, void *mem, size_t nrw,
ssize_t r;
int saved_errno;
int flags;
int positional_rw = 0;
int positional_rw;
if (mem == NULL)
goto err_prw;
@@ -1695,16 +1695,19 @@ prw(int fd, void *mem, size_t nrw,
r = -1;
if (rw_type >= IO_PREAD)
positional_rw = 1; /* pread/pwrite */
else
positional_rw = 0; /* read/write */
try_rw_again:
if (rw_type == IO_WRITE)
r = write(fd, mem, nrw);
else if (rw_type == IO_READ)
r = read(fd, mem, nrw);
else
positional_rw = 1;
if (!positional_rw) {
if (rw_type == IO_WRITE)
r = write(fd, mem, nrw);
else if (rw_type == IO_READ)
r = read(fd, mem, nrw);
if (r == -1 && (errno == EINTR
|| errno == err_eagain(loop_eagain)))
goto try_rw_again;