Skip to content

Commit

Permalink
Make uio_init take iov/iovcnt
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Dec 25, 2024
1 parent cf57647 commit 8283811
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
8 changes: 2 additions & 6 deletions fs/vfs/fs_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes)

iov.iov_base = buf;
iov.iov_len = nbytes;
uio_init(&uio);
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
uio_init(&uio, &iov, 1);
return file_readv(filep, &uio);
}

Expand Down Expand Up @@ -256,9 +254,7 @@ ssize_t nx_readv(int fd, FAR const struct iovec *iov, int iovcnt)

/* Then let file_readv do all of the work. */

uio_init(&uio);
uio.uio_iov = iov;
uio.uio_iovcnt = iovcnt;
uio_init(&uio, iov, iovcnt);
ret = file_readv(filep, &uio);
fs_putfilep(filep);
return ret;
Expand Down
4 changes: 3 additions & 1 deletion fs/vfs/fs_uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ void uio_advance(FAR struct uio *uio, size_t sz)
*
****************************************************************************/

void uio_init(FAR struct uio *uio)
void uio_init(FAR struct uio *uio, FAR const struct iovec *iov, int iovcnt)
{
memset(uio, 0, sizeof(*uio));
uio->uio_iov = iov;
uio->uio_iovcnt = iovcnt;
}

/****************************************************************************
Expand Down
8 changes: 2 additions & 6 deletions fs/vfs/fs_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ ssize_t file_write(FAR struct file *filep, FAR const void *buf,

iov.iov_base = (FAR void *)buf;
iov.iov_len = nbytes;
uio_init(&uio);
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
uio_init(&uio, &iov, 1);
return file_writev(filep, &uio);
}

Expand Down Expand Up @@ -258,9 +256,7 @@ ssize_t nx_writev(int fd, FAR const struct iovec *iov, int iovcnt)
* index. Note that file_writev() will return the errno on failure.
*/

uio_init(&uio);
uio.uio_iov = iov;
uio.uio_iovcnt = iovcnt;
uio_init(&uio, iov, iovcnt);
ret = file_writev(filep, &uio);
fs_putfilep(filep);
}
Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/fs/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void uio_advance(FAR struct uio *uio, size_t sz);
*
****************************************************************************/

void uio_init(FAR struct uio *uio);
void uio_init(FAR struct uio *uio, FAR const struct iovec *iov, int iovcnt);

/****************************************************************************
* Name: uio_copyto
Expand Down

0 comments on commit 8283811

Please sign in to comment.