mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-21 00:27:09 +02:00
util/nvmutil: don't use bad pointer cast in prw
in practise it's ok, but some compilers might complain. all this change costs is a bit of branching inside a loop, but compilers will sort that out. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+8
-11
@@ -1468,16 +1468,6 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
off_t off_orig;
|
off_t off_orig;
|
||||||
ssize_t r;
|
ssize_t r;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
ssize_t (*op)(int, void *, size_t);
|
|
||||||
|
|
||||||
if (rw_type == PLESEN)
|
|
||||||
op = read;
|
|
||||||
else if (rw_type == PSCHREIB)
|
|
||||||
op = (ssize_t (*)(int, void *, size_t))write;
|
|
||||||
else {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1485,7 +1475,14 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
r = op(fd, mem, nrw);
|
if (rw_type == PLESEN)
|
||||||
|
r = read(fd, mem, nrw);
|
||||||
|
else if (rw_type == PSCHREIB)
|
||||||
|
r = write(fd, mem, nrw);
|
||||||
|
else {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} while (r < 0 && errno == EINTR);
|
} while (r < 0 && errno == EINTR);
|
||||||
|
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
|
|||||||
Reference in New Issue
Block a user