mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
util/nvmutil: tidy up prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+11
-8
@@ -1681,7 +1681,7 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
ssize_t r;
|
ssize_t r;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
int flags;
|
int flags;
|
||||||
int positional_rw = 0;
|
int positional_rw;
|
||||||
|
|
||||||
if (mem == NULL)
|
if (mem == NULL)
|
||||||
goto err_prw;
|
goto err_prw;
|
||||||
@@ -1695,16 +1695,19 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
|
|
||||||
r = -1;
|
r = -1;
|
||||||
|
|
||||||
|
if (rw_type >= IO_PREAD)
|
||||||
|
positional_rw = 1; /* pread/pwrite */
|
||||||
|
else
|
||||||
|
positional_rw = 0; /* read/write */
|
||||||
|
|
||||||
try_rw_again:
|
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 (!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
|
if (r == -1 && (errno == EINTR
|
||||||
|| errno == err_eagain(loop_eagain)))
|
|| errno == err_eagain(loop_eagain)))
|
||||||
goto try_rw_again;
|
goto try_rw_again;
|
||||||
|
|||||||
Reference in New Issue
Block a user