mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
uutils: Remove use of mem::uninitialized (#3808)
This commit is contained in:
parent
e2bab1d515
commit
c7b988c825
2 changed files with 9 additions and 8 deletions
|
@ -543,14 +543,18 @@ fn auditid() {}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||||
fn auditid() {
|
fn auditid() {
|
||||||
#[allow(deprecated)]
|
use std::mem::MaybeUninit;
|
||||||
let mut auditinfo: audit::c_auditinfo_addr_t = unsafe { std::mem::uninitialized() };
|
|
||||||
let address = &mut auditinfo as *mut audit::c_auditinfo_addr_t;
|
let mut auditinfo: MaybeUninit<audit::c_auditinfo_addr_t> = MaybeUninit::uninit();
|
||||||
|
let address = auditinfo.as_mut_ptr();
|
||||||
if unsafe { audit::getaudit(address) } < 0 {
|
if unsafe { audit::getaudit(address) } < 0 {
|
||||||
println!("couldn't retrieve information");
|
println!("couldn't retrieve information");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SAFETY: getaudit wrote a valid struct to auditinfo
|
||||||
|
let auditinfo = unsafe { auditinfo.assume_init() };
|
||||||
|
|
||||||
println!("auid={}", auditinfo.ai_auid);
|
println!("auid={}", auditinfo.ai_auid);
|
||||||
println!("mask.success=0x{:x}", auditinfo.ai_mask.am_success);
|
println!("mask.success=0x{:x}", auditinfo.ai_mask.am_success);
|
||||||
println!("mask.failure=0x{:x}", auditinfo.ai_mask.am_failure);
|
println!("mask.failure=0x{:x}", auditinfo.ai_mask.am_failure);
|
||||||
|
|
|
@ -71,7 +71,6 @@ mod platform {
|
||||||
use self::winapi::um::winbase;
|
use self::winapi::um::winbase;
|
||||||
use self::winapi::um::winnt;
|
use self::winapi::um::winnt;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::mem;
|
|
||||||
use std::os::windows::prelude::*;
|
use std::os::windows::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use uucore::crash;
|
use uucore::crash;
|
||||||
|
@ -99,8 +98,7 @@ mod platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn find_first_volume() -> (String, winnt::HANDLE) {
|
unsafe fn find_first_volume() -> (String, winnt::HANDLE) {
|
||||||
#[allow(deprecated)]
|
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = [0; minwindef::MAX_PATH];
|
||||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
|
||||||
let handle = winapi::um::fileapi::FindFirstVolumeW(
|
let handle = winapi::um::fileapi::FindFirstVolumeW(
|
||||||
name.as_mut_ptr(),
|
name.as_mut_ptr(),
|
||||||
name.len() as minwindef::DWORD,
|
name.len() as minwindef::DWORD,
|
||||||
|
@ -118,8 +116,7 @@ mod platform {
|
||||||
let (first_volume, next_volume_handle) = find_first_volume();
|
let (first_volume, next_volume_handle) = find_first_volume();
|
||||||
let mut volumes = vec![first_volume];
|
let mut volumes = vec![first_volume];
|
||||||
loop {
|
loop {
|
||||||
#[allow(deprecated)]
|
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = [0; minwindef::MAX_PATH];
|
||||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
|
||||||
if winapi::um::fileapi::FindNextVolumeW(
|
if winapi::um::fileapi::FindNextVolumeW(
|
||||||
next_volume_handle,
|
next_volume_handle,
|
||||||
name.as_mut_ptr(),
|
name.as_mut_ptr(),
|
||||||
|
|
Loading…
Reference in a new issue