(pxar: replace deprecated std::mem::uninitialized()
... and use std::mem::MaybeUninit or proxmox::tools::vec::uninitialized() instead. Signed-off-by: Christian Ebner <c.ebner@proxmox.com> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
5e58e1bb7d
commit
1af30bc2fe
|
@ -1141,9 +1141,10 @@ fn errno_is_unsupported(errno: Errno) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn detect_fs_type(fd: RawFd) -> Result<i64, Error> {
|
fn detect_fs_type(fd: RawFd) -> Result<i64, Error> {
|
||||||
let mut fs_stat: libc::statfs = unsafe { std::mem::uninitialized() };
|
let mut fs_stat = std::mem::MaybeUninit::uninit();
|
||||||
let res = unsafe { libc::fstatfs(fd, &mut fs_stat) };
|
let res = unsafe { libc::fstatfs(fd, fs_stat.as_mut_ptr()) };
|
||||||
Errno::result(res)?;
|
Errno::result(res)?;
|
||||||
|
let fs_stat = unsafe { fs_stat.assume_init() };
|
||||||
|
|
||||||
Ok(fs_stat.f_type)
|
Ok(fs_stat.f_type)
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,14 +67,15 @@ impl <R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<R, F> {
|
||||||
|
|
||||||
pub (crate) fn read_item<T: Endian>(&mut self) -> Result<T, Error> {
|
pub (crate) fn read_item<T: Endian>(&mut self) -> Result<T, Error> {
|
||||||
|
|
||||||
let mut result: T = unsafe { std::mem::uninitialized() };
|
let mut result = std::mem::MaybeUninit::<T>::uninit();
|
||||||
|
|
||||||
let buffer = unsafe { std::slice::from_raw_parts_mut(
|
let buffer = unsafe { std::slice::from_raw_parts_mut(
|
||||||
&mut result as *mut T as *mut u8,
|
result.as_mut_ptr() as *mut u8,
|
||||||
std::mem::size_of::<T>()
|
std::mem::size_of::<T>()
|
||||||
)};
|
)};
|
||||||
|
|
||||||
self.reader.read_exact(buffer)?;
|
self.reader.read_exact(buffer)?;
|
||||||
|
let result = unsafe { result.assume_init() };
|
||||||
|
|
||||||
Ok(result.from_le())
|
Ok(result.from_le())
|
||||||
}
|
}
|
||||||
|
@ -576,7 +577,6 @@ impl <R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<R, F> {
|
||||||
entry: &PxarEntry,
|
entry: &PxarEntry,
|
||||||
filename: &OsStr
|
filename: &OsStr
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let mut read_buffer: [u8; 64*1024] = unsafe { std::mem::uninitialized() };
|
|
||||||
let (head, attr) = self.read_attributes()
|
let (head, attr) = self.read_attributes()
|
||||||
.map_err(|err| format_err!("Reading of file attributes failed - {}", err))?;
|
.map_err(|err| format_err!("Reading of file attributes failed - {}", err))?;
|
||||||
|
|
||||||
|
@ -595,6 +595,7 @@ impl <R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<R, F> {
|
||||||
}
|
}
|
||||||
let need = (head.size - HEADER_SIZE) as usize;
|
let need = (head.size - HEADER_SIZE) as usize;
|
||||||
|
|
||||||
|
let mut read_buffer = unsafe { vec::uninitialized(64 * 1024) };
|
||||||
let mut done = 0;
|
let mut done = 0;
|
||||||
while done < need {
|
while done < need {
|
||||||
let todo = need - done;
|
let todo = need - done;
|
||||||
|
|
Loading…
Reference in New Issue