From c39859c8d065b8321cc814761d23ac88b76031ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Oko=C5=84ski?= Date: Mon, 11 Jun 2018 05:56:35 +0200 Subject: [PATCH] Make preadv take immutable slice of IoVecs, fixes #913 --- CHANGELOG.md | 2 ++ src/sys/uio.rs | 2 +- test/sys/test_uio.rs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69484bbff6..465ddb64a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed ### Fixed +- Made `preadv` take immutable slice of IoVec. + ([#944](https://github.com/nix-rust/nix/pull/914)) ### Removed diff --git a/src/sys/uio.rs b/src/sys/uio.rs index 305c2ad0c1..45860be5aa 100644 --- a/src/sys/uio.rs +++ b/src/sys/uio.rs @@ -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 { let res = unsafe { libc::preadv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset) diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs index c6331f1d7b..9f56c810a1 100644 --- a/test/sys/test_uio.rs +++ b/test/sys/test_uio.rs @@ -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();