mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +00:00
refactor/polish ~ fix cargo clippy
complaints (fatal/cast_ptr_alignment)
This commit is contained in:
parent
c969becbf8
commit
1f137c245f
1 changed files with 8 additions and 2 deletions
10
src/cp/cp.rs
10
src/cp/cp.rs
|
@ -34,13 +34,18 @@ use kernel32::CreateFileW;
|
|||
extern crate winapi;
|
||||
|
||||
use std::mem;
|
||||
#[cfg(not(windows))]
|
||||
use std::ffi::CString;
|
||||
#[cfg(windows)]
|
||||
use std::ffi::OsStr;
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use quick_error::ResultExt;
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::io::{stdin, stdout, Write};
|
||||
use std::io;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
use std::path::{Path, PathBuf, StripPrefixError};
|
||||
use std::str::FromStr;
|
||||
use uucore::fs::{canonicalize, CanonicalizeMode};
|
||||
|
@ -712,11 +717,11 @@ fn preserve_hardlinks(
|
|||
{
|
||||
if !source.is_dir() {
|
||||
unsafe {
|
||||
let src_path = CString::new(source.as_os_str().to_str().unwrap()).unwrap();
|
||||
let inode: u64;
|
||||
let nlinks: u64;
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let src_path = CString::new(source.as_os_str().to_str().unwrap()).unwrap();
|
||||
let mut stat = mem::zeroed();
|
||||
if libc::lstat(src_path.as_ptr(), &mut stat) < 0 {
|
||||
return Err(format!(
|
||||
|
@ -730,9 +735,10 @@ fn preserve_hardlinks(
|
|||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let src_path: Vec<u16> = OsStr::new(source).encode_wide().collect();
|
||||
let stat = mem::uninitialized();
|
||||
let handle = CreateFileW(
|
||||
src_path.as_ptr() as *const u16,
|
||||
src_path.as_ptr(),
|
||||
winapi::um::winnt::GENERIC_READ,
|
||||
winapi::um::winnt::FILE_SHARE_READ,
|
||||
std::ptr::null_mut(),
|
||||
|
|
Loading…
Reference in a new issue