mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #1078 from shutefan/fix-warnings-in-cp
cp: fix compiler warnings
This commit is contained in:
commit
42be38f98f
4 changed files with 18 additions and 18 deletions
|
@ -65,9 +65,9 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &getopts::Matches) {
|
||||||
|
|
||||||
let delim : Vec<String> = (0 .. 4).map(|col| mkdelim(col, opts)).collect();
|
let delim : Vec<String> = (0 .. 4).map(|col| mkdelim(col, opts)).collect();
|
||||||
|
|
||||||
let mut ra = &mut String::new();
|
let ra = &mut String::new();
|
||||||
let mut na = a.read_line(ra);
|
let mut na = a.read_line(ra);
|
||||||
let mut rb = &mut String::new();
|
let rb = &mut String::new();
|
||||||
let mut nb = b.read_line(rb);
|
let mut nb = b.read_line(rb);
|
||||||
|
|
||||||
while na.is_ok() || nb.is_ok() {
|
while na.is_ok() || nb.is_ok() {
|
||||||
|
|
28
src/cp/cp.rs
28
src/cp/cp.rs
|
@ -50,9 +50,6 @@ use std::fs::File;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
use libc::{c_int, c_char};
|
|
||||||
|
|
||||||
#[cfg(unix)] use std::os::unix::fs::PermissionsExt;
|
#[cfg(unix)] use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")] ioctl!(write ficlone with 0x94, 9; std::os::raw::c_int);
|
#[cfg(target_os = "linux")] ioctl!(write ficlone with 0x94, 9; std::os::raw::c_int);
|
||||||
|
@ -681,16 +678,16 @@ fn preserve_hardlinks(hard_links: &mut Vec<(String, u64)>, source: &std::path::P
|
||||||
if !source.is_dir() {
|
if !source.is_dir() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let src_path = CString::new(source.as_os_str().to_str().unwrap()).unwrap();
|
let src_path = CString::new(source.as_os_str().to_str().unwrap()).unwrap();
|
||||||
let mut inode: u64 = 0;
|
let inode: u64;
|
||||||
let mut nlinks = 0;
|
let nlinks: u64;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
let mut stat = mem::zeroed();
|
let mut stat = mem::zeroed();
|
||||||
if libc::lstat(src_path.as_ptr(), &mut stat) < 0 {
|
if libc::lstat(src_path.as_ptr(), &mut stat) < 0 {
|
||||||
return Err(format!("cannot stat {:?}: {}", src_path, std::io::Error::last_os_error()).into());
|
return Err(format!("cannot stat {:?}: {}", src_path, std::io::Error::last_os_error()).into());
|
||||||
}
|
}
|
||||||
inode = stat.st_ino;
|
inode = stat.st_ino as u64;
|
||||||
nlinks = stat.st_nlink;
|
nlinks = stat.st_nlink as u64;
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
@ -704,7 +701,7 @@ fn preserve_hardlinks(hard_links: &mut Vec<(String, u64)>, source: &std::path::P
|
||||||
return Err(format!("cannot get file information {:?}: {}", source, std::io::Error::last_os_error()).into());
|
return Err(format!("cannot get file information {:?}: {}", source, std::io::Error::last_os_error()).into());
|
||||||
}
|
}
|
||||||
inode = (((*stat).nFileIndexHigh as u64) << 32 | (*stat).nFileIndexLow as u64);
|
inode = (((*stat).nFileIndexHigh as u64) << 32 | (*stat).nFileIndexLow as u64);
|
||||||
nlinks = (*stat).nNumberOfLinks;
|
nlinks = (*stat).nNumberOfLinks as u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
for hard_link in hard_links.iter() {
|
for hard_link in hard_links.iter() {
|
||||||
|
@ -750,7 +747,6 @@ fn copy(sources: &[Source], target: &Target, options: &Options) -> CopyResult<()
|
||||||
let mut found_hard_link = false;
|
let mut found_hard_link = false;
|
||||||
if preserve_hard_links {
|
if preserve_hard_links {
|
||||||
let dest = construct_dest_path(source, target, &target_type, options)?;
|
let dest = construct_dest_path(source, target, &target_type, options)?;
|
||||||
let src_path = CString::new(Path::new(&source.clone()).as_os_str().to_str().unwrap()).unwrap();
|
|
||||||
preserve_hardlinks(&mut hard_links, source, dest, &mut found_hard_link).unwrap();
|
preserve_hardlinks(&mut hard_links, source, dest, &mut found_hard_link).unwrap();
|
||||||
}
|
}
|
||||||
if !found_hard_link {
|
if !found_hard_link {
|
||||||
|
@ -907,7 +903,7 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu
|
||||||
let xattrs = xattr::list(source)?;
|
let xattrs = xattr::list(source)?;
|
||||||
for attr in xattrs {
|
for attr in xattrs {
|
||||||
if let Some(attr_value) = xattr::get(source, attr.clone())? {
|
if let Some(attr_value) = xattr::get(source, attr.clone())? {
|
||||||
xattr::set(dest, attr, &attr_value[..]);
|
crash_if_err!(EXIT_ERR, xattr::set(dest, attr, &attr_value[..]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,10 +984,14 @@ fn copy_file(source: &Path, dest: &Path, options: &Options) -> CopyResult<()> {
|
||||||
println!("{}", context_for(source, dest));
|
println!("{}", context_for(source, dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut preserve_context = false;
|
#[allow(unused)]
|
||||||
for attribute in &options.preserve_attributes {
|
{
|
||||||
if *attribute == Attribute::Context {
|
// TODO: implement --preserve flag
|
||||||
preserve_context = true;
|
let mut preserve_context = false;
|
||||||
|
for attribute in &options.preserve_attributes {
|
||||||
|
if *attribute == Attribute::Context {
|
||||||
|
preserve_context = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl UnescapedText {
|
||||||
let mut new_text = UnescapedText::new();
|
let mut new_text = UnescapedText::new();
|
||||||
let mut tmp_str = String::new();
|
let mut tmp_str = String::new();
|
||||||
{
|
{
|
||||||
let mut new_vec: &mut Vec<u8> = &mut (new_text.0);
|
let new_vec: &mut Vec<u8> = &mut (new_text.0);
|
||||||
while let Some(ch) = it.next() {
|
while let Some(ch) = it.next() {
|
||||||
if !addchar {
|
if !addchar {
|
||||||
addchar = true;
|
addchar = true;
|
||||||
|
|
|
@ -137,7 +137,7 @@ fn next_tabstop(tabstops: &[usize], col: usize) -> Option<usize> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_tabs(mut output: &mut BufWriter<Stdout>, tabstops: &[usize],
|
fn write_tabs(output: &mut BufWriter<Stdout>, tabstops: &[usize],
|
||||||
mut scol: usize, col: usize, prevtab: bool, init: bool, amode: bool) {
|
mut scol: usize, col: usize, prevtab: bool, init: bool, amode: bool) {
|
||||||
// This conditional establishes the following:
|
// This conditional establishes the following:
|
||||||
// We never turn a single space before a non-blank into
|
// We never turn a single space before a non-blank into
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue