mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
refactor/polish ~ fix cargo clippy
complaints (allow deprecated mem::uninitialized)
.# [why] `std::mem::MaybeUninit` is likely preffered. But `MaybeUninit` was not stabilized until rust v1.36.0 and conversion from `mem::uninitialized` is not obviously straight-forward at the moment. So, 'std::mem::uninitialized' is allowed instead of increasing MinSRV to v1.36.0. * ref: https://github.com/rust-lang/rust/blob/master/RELEASES.md
This commit is contained in:
parent
082f9520b2
commit
a6bdad314d
6 changed files with 9 additions and 4 deletions
|
@ -739,6 +739,7 @@ fn preserve_hardlinks(
|
|||
#[cfg(windows)]
|
||||
{
|
||||
let src_path: Vec<u16> = OsStr::new(source).encode_wide().collect();
|
||||
#[allow(deprecated)]
|
||||
let stat = mem::uninitialized();
|
||||
let handle = CreateFileW(
|
||||
src_path.as_ptr(),
|
||||
|
|
|
@ -46,6 +46,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
#![allow(clippy::let_and_return)]
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
#[allow(deprecated)]
|
||||
let mut data = std::mem::uninitialized();
|
||||
if WSAStartup(MAKEWORD(2, 2), &mut data as *mut _) != 0 {
|
||||
eprintln!("Failed to start Winsock 2.2");
|
||||
|
|
|
@ -30,7 +30,6 @@ macro_rules! cstr2cow {
|
|||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
mod audit {
|
||||
pub use std::mem::uninitialized;
|
||||
use super::libc::{c_int, c_uint, dev_t, pid_t, uid_t, uint64_t};
|
||||
|
||||
pub type au_id_t = uid_t;
|
||||
|
@ -278,7 +277,8 @@ fn auditid() {}
|
|||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn auditid() {
|
||||
let mut auditinfo: audit::c_auditinfo_addr_t = unsafe { audit::uninitialized() };
|
||||
#[allow(deprecated)]
|
||||
let mut auditinfo: audit::c_auditinfo_addr_t = unsafe { std::mem::uninitialized() };
|
||||
let address = &mut auditinfo as *mut audit::c_auditinfo_addr_t;
|
||||
if unsafe { audit::getaudit(address) } < 0 {
|
||||
println!("couldn't retrieve information");
|
||||
|
|
|
@ -72,6 +72,7 @@ mod platform {
|
|||
}
|
||||
|
||||
unsafe fn find_first_volume() -> (String, winnt::HANDLE) {
|
||||
#[allow(deprecated)]
|
||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
||||
let handle = kernel32::FindFirstVolumeW(name.as_mut_ptr(), name.len() as minwindef::DWORD);
|
||||
if handle == handleapi::INVALID_HANDLE_VALUE {
|
||||
|
@ -87,6 +88,7 @@ mod platform {
|
|||
let (first_volume, next_volume_handle) = find_first_volume();
|
||||
let mut volumes = vec![first_volume];
|
||||
loop {
|
||||
#[allow(deprecated)]
|
||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
||||
if kernel32::FindNextVolumeW(
|
||||
next_volume_handle,
|
||||
|
|
|
@ -21,7 +21,6 @@ use getopts::Options;
|
|||
use libc::{S_IFLNK, S_IFMT, S_IFREG};
|
||||
use libc::{lstat, stat, unlink};
|
||||
use std::io::{Error, ErrorKind};
|
||||
use std::mem::uninitialized;
|
||||
use std::ffi::CString;
|
||||
|
||||
static NAME: &str = "unlink";
|
||||
|
@ -71,7 +70,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
let c_string = CString::new(matches.free[0].clone()).unwrap(); // unwrap() cannot fail, the string comes from argv so it cannot contain a \0.
|
||||
|
||||
let st_mode = {
|
||||
let mut buf: stat = unsafe { uninitialized() };
|
||||
#[allow(deprecated)]
|
||||
let mut buf: stat = unsafe { std::mem::uninitialized() };
|
||||
let result = unsafe {
|
||||
lstat(
|
||||
c_string.as_ptr(),
|
||||
|
|
|
@ -19,6 +19,7 @@ use self::winapi::shared::lmcons;
|
|||
use self::winapi::shared::minwindef;
|
||||
|
||||
pub unsafe fn getusername() -> Result<String> {
|
||||
#[allow(deprecated)]
|
||||
let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized();
|
||||
let mut len = buffer.len() as minwindef::DWORD;
|
||||
if advapi32::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
|
||||
|
|
Loading…
Reference in a new issue