Skip to content

Commit

Permalink
Replace preadv and pwritev with pread and pwrite
Browse files Browse the repository at this point in the history
Fixes build errors on OS X and has better readability.

Signed-off-by: Clemens Gruber <clemensgru@gmail.com>
  • Loading branch information
clemensg committed Dec 10, 2015
1 parent 8365a04 commit de4282e
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,7 @@ int rtc_close(struct rtc_handle *handle)

int file_write(int fd, void *buf, size_t sz)
{
struct iovec iov[1];
ssize_t ret;
iov[0].iov_base = buf;
iov[0].iov_len = sz;
ret = IGNORE_EINTR (pwritev (fd, iov, 1, 0));
if (ret != sz)
if (IGNORE_EINTR(pwrite(fd, buf, sz, 0)) != sz)
{
return -1;
}
Expand Down Expand Up @@ -329,10 +324,7 @@ int file_close(int fd)

int file_read(int fd, void *buf, size_t sz)
{
struct iovec iov[1];
iov[0].iov_base = buf;
iov[0].iov_len = sz;
if (preadv (fd, iov, 1, 0) != sz)
if (pread(fd, buf, sz, 0) != sz)
{
/* Returns -1 on read failure */
return -1;
Expand Down

0 comments on commit de4282e

Please sign in to comment.