Skip to content

Commit

Permalink
Merge #914
Browse files Browse the repository at this point in the history
914: Make preadv take immutable slice of IoVecs r=asomers a=farnoy

fixes #913

I filled in the CHANGELOG, but I see that it usually links to PRs and not issues, do you want me to change it or remove and leave for you to describe?

This change seems to be strictly backwards-compatible, I didn't have to change the test for it to work.

Co-authored-by: Jakub Okoński <[email protected]>
  • Loading branch information
bors[bot] and farnoy committed Jul 3, 2018
2 parents 8a9b86e + db4ea2b commit c62f1f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed

### Fixed
- Made `preadv` take immutable slice of IoVec.
([#914](https://github.com/nix-rust/nix/pull/914))

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/sys/uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>],
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
pub fn preadv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>],
pub fn preadv(fd: RawFd, iov: &[IoVec<&mut [u8]>],
offset: off_t) -> Result<usize> {
let res = unsafe {
libc::preadv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset)
Expand Down
4 changes: 2 additions & 2 deletions test/sys/test_uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ fn test_preadv() {

{
// Borrow the buffers into IoVecs and preadv into them
let mut iovecs: Vec<_> = buffers.iter_mut().map(
let iovecs: Vec<_> = buffers.iter_mut().map(
|buf| IoVec::from_mut_slice(&mut buf[..])).collect();
assert_eq!(Ok(100), preadv(file.as_raw_fd(), &mut iovecs, 100));
assert_eq!(Ok(100), preadv(file.as_raw_fd(), &iovecs, 100));
}

let all = buffers.concat();
Expand Down

0 comments on commit c62f1f8

Please sign in to comment.