diff --git a/src/comm/comm.rs b/src/comm/comm.rs index 749daa501..98f5b742b 100644 --- a/src/comm/comm.rs +++ b/src/comm/comm.rs @@ -65,9 +65,9 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &getopts::Matches) { let delim : Vec = (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 rb = &mut String::new(); + let rb = &mut String::new(); let mut nb = b.read_line(rb); while na.is_ok() || nb.is_ok() { diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 1730ad43b..fc51df701 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -50,9 +50,6 @@ use std::fs::File; use std::fs::OpenOptions; use filetime::FileTime; -#[cfg(target_os = "linux")] -use libc::{c_int, c_char}; - #[cfg(unix)] use std::os::unix::fs::PermissionsExt; #[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() { unsafe { let src_path = CString::new(source.as_os_str().to_str().unwrap()).unwrap(); - let mut inode: u64 = 0; - let mut nlinks = 0; + let inode: u64; + let nlinks: u64; #[cfg(unix)] { let mut stat = mem::zeroed(); if libc::lstat(src_path.as_ptr(), &mut stat) < 0 { return Err(format!("cannot stat {:?}: {}", src_path, std::io::Error::last_os_error()).into()); } - inode = stat.st_ino; - nlinks = stat.st_nlink; + inode = stat.st_ino as u64; + nlinks = stat.st_nlink as u64; } #[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()); } 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() { @@ -750,7 +747,6 @@ fn copy(sources: &[Source], target: &Target, options: &Options) -> CopyResult<() let mut found_hard_link = false; if preserve_hard_links { 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(); } if !found_hard_link { @@ -907,7 +903,7 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu let xattrs = xattr::list(source)?; for attr in xattrs { 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)); } - let mut preserve_context = false; - for attribute in &options.preserve_attributes { - if *attribute == Attribute::Context { - preserve_context = true; + #[allow(unused)] + { + // TODO: implement --preserve flag + let mut preserve_context = false; + for attribute in &options.preserve_attributes { + if *attribute == Attribute::Context { + preserve_context = true; + } } } diff --git a/src/printf/tokenize/unescaped_text.rs b/src/printf/tokenize/unescaped_text.rs index 45f006fdf..50eecc8ec 100644 --- a/src/printf/tokenize/unescaped_text.rs +++ b/src/printf/tokenize/unescaped_text.rs @@ -179,7 +179,7 @@ impl UnescapedText { let mut new_text = UnescapedText::new(); let mut tmp_str = String::new(); { - let mut new_vec: &mut Vec = &mut (new_text.0); + let new_vec: &mut Vec = &mut (new_text.0); while let Some(ch) = it.next() { if !addchar { addchar = true; diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index 556f97119..dbbe417bd 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -137,7 +137,7 @@ fn next_tabstop(tabstops: &[usize], col: usize) -> Option { } } -fn write_tabs(mut output: &mut BufWriter, tabstops: &[usize], +fn write_tabs(output: &mut BufWriter, tabstops: &[usize], mut scol: usize, col: usize, prevtab: bool, init: bool, amode: bool) { // This conditional establishes the following: // We never turn a single space before a non-blank into