diff options
author | Sendil Kumar <sendilkumarn@live.com> | 2019-08-22 22:22:29 +0200 |
---|---|---|
committer | Sendil Kumar <sendilkumarn@live.com> | 2019-08-22 22:22:29 +0200 |
commit | 4a4cfc0b4ed9bb30c0be09d8d7e49b8fb8e2e805 (patch) | |
tree | b370cb45e2bd82ab6ed9384245a5f8497099673e /src | |
parent | 67375852b45636c251faeb2e6be43bdf40d709a4 (diff) | |
download | nix-4a4cfc0b4ed9bb30c0be09d8d7e49b8fb8e2e805.zip |
updated changelog
Diffstat (limited to 'src')
-rw-r--r-- | src/fcntl.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/fcntl.rs b/src/fcntl.rs index 1ef26271..08c339a9 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -188,10 +188,9 @@ fn wrap_readlink_result(v: &mut Vec<u8>, res: ssize_t) -> Result<OsString> { } pub fn readlink<'a, P: ?Sized + NixPath>(path: &P) -> Result<OsString> { - let len = libc::PATH_MAX as usize; - let mut v = Vec::with_capacity(len); + let mut v = Vec::with_capacity(libc::PATH_MAX as usize); let res = path.with_nix_path(|cstr| { - unsafe { libc::readlink(cstr.as_ptr(), v.as_mut_ptr() as *mut c_char, len as size_t) } + unsafe { libc::readlink(cstr.as_ptr(), v.as_mut_ptr() as *mut c_char, v.capacity() as size_t) } })?; wrap_readlink_result(&mut v, res) @@ -199,10 +198,9 @@ pub fn readlink<'a, P: ?Sized + NixPath>(path: &P) -> Result<OsString> { pub fn readlinkat<'a, P: ?Sized + NixPath>(dirfd: RawFd, path: &P) -> Result<OsString> { - let len = libc::PATH_MAX as usize; - let mut v = Vec::with_capacity(len); + let mut v = Vec::with_capacity(libc::PATH_MAX as usize); let res = path.with_nix_path(|cstr| { - unsafe { libc::readlinkat(dirfd, cstr.as_ptr(), v.as_mut_ptr() as *mut c_char, len as size_t) } + unsafe { libc::readlinkat(dirfd, cstr.as_ptr(), v.as_mut_ptr() as *mut c_char, v.capacity() as size_t) } })?; wrap_readlink_result(&mut v, res) |