Use mutable pointers for Unix path buffers

This commit is contained in:
John Kåre Alsaker
2026-04-12 18:00:57 +02:00
parent 12f35ad39e
commit 7a47964d3f
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -339,7 +339,7 @@ fn get_path(fd: c_int) -> Option<PathBuf> {
// alternatives. If a better method is invented, it should be used
// instead.
let mut buf = vec![0; libc::PATH_MAX as usize];
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_ptr()) };
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_mut_ptr()) };
if n == -1 {
cfg_select! {
target_os = "netbsd" => {
@@ -375,7 +375,7 @@ fn get_path(fd: c_int) -> Option<PathBuf> {
#[cfg(target_os = "vxworks")]
fn get_path(fd: c_int) -> Option<PathBuf> {
let mut buf = vec![0; libc::PATH_MAX as usize];
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_ptr()) };
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_mut_ptr()) };
if n == -1 {
return None;
}
+1 -1
View File
@@ -207,7 +207,7 @@ fn sysctl() -> io::Result<PathBuf> {
cvt(libc::sysctl(
mib.as_ptr(),
mib.len() as libc::c_uint,
path.as_ptr() as *mut libc::c_void,
path.as_mut_ptr() as *mut libc::c_void,
&mut path_len,
ptr::null(),
0,