Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ pedantic = { level = "deny", priority = -1 }
# Eventually the clippy settings from the `[lints]` section should be moved here.
# In order to use these, all crates have `[lints] workspace = true` section.
[workspace.lints.rust]
# unused_qualifications = "warn"
unused_qualifications = "warn"

[workspace.lints.clippy]
all = { level = "deny", priority = -1 }
Expand Down
2 changes: 1 addition & 1 deletion src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
.arg(
Arg::new(options::FILE)
.index(1)
.action(clap::ArgAction::Append)
.action(ArgAction::Append)
.value_hint(clap::ValueHint::FilePath),
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn uu_app() -> Command {
)
.arg(
Arg::new(options::NAME)
.action(clap::ArgAction::Append)
.action(ArgAction::Append)
.value_hint(clap::ValueHint::AnyPath)
.hide(true)
.trailing_var_arg(true),
Expand Down
10 changes: 5 additions & 5 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl LineNumber {
}
}

fn write(&self, writer: &mut impl Write) -> std::io::Result<()> {
fn write(&self, writer: &mut impl Write) -> io::Result<()> {
writer.write_all(&self.buf)
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::FILE)
.hide(true)
.action(clap::ArgAction::Append)
.action(ArgAction::Append)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Expand Down Expand Up @@ -377,7 +377,7 @@ fn cat_handle<R: FdReadable>(
/// Whether this process is appending to stdout.
#[cfg(unix)]
fn is_appending() -> bool {
let stdout = std::io::stdout();
let stdout = io::stdout();
let flags = match fcntl(stdout.as_raw_fd(), FcntlArg::F_GETFL) {
Ok(flags) => flags,
Err(_) => return false,
Expand All @@ -404,7 +404,7 @@ fn cat_path(
let in_info = FileInformation::from_file(&stdin)?;
let mut handle = InputHandle {
reader: stdin,
is_interactive: std::io::stdin().is_terminal(),
is_interactive: io::stdin().is_terminal(),
};
if let Some(out_info) = out_info {
if in_info == *out_info && is_appending() {
Expand Down Expand Up @@ -445,7 +445,7 @@ fn cat_path(
}

fn cat_files(files: &[String], options: &OutputOptions) -> UResult<()> {
let out_info = FileInformation::from_file(&std::io::stdout()).ok();
let out_info = FileInformation::from_file(&io::stdout()).ok();

let mut state = OutputState {
line_number: LineNumber::new(),
Expand Down
2 changes: 1 addition & 1 deletion src/uu/chcon/src/chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ struct Options {
files: Vec<PathBuf>,
}

fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result<Options> {
fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Options> {
let matches = config.try_get_matches_from(args)?;

let verbose = matches.get_flag(options::VERBOSE);
Expand Down
5 changes: 2 additions & 3 deletions src/uu/chcon/src/fts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::ffi::{CStr, CString, OsStr};
use std::marker::PhantomData;
use std::os::raw::{c_int, c_long, c_short};
use std::path::Path;
use std::ptr::NonNull;
use std::{io, iter, ptr, slice};

use crate::errors::{Error, Result};
Expand Down Expand Up @@ -71,7 +70,7 @@ impl FTS {
// pointer assumed to be valid.
let new_entry = unsafe { fts_sys::fts_read(self.fts.as_ptr()) };

self.entry = NonNull::new(new_entry);
self.entry = ptr::NonNull::new(new_entry);
if self.entry.is_none() {
let r = io::Error::last_os_error();
if let Some(0) = r.raw_os_error() {
Expand Down Expand Up @@ -161,7 +160,7 @@ impl<'fts> EntryRef<'fts> {
return None;
}

NonNull::new(entry.fts_path)
ptr::NonNull::new(entry.fts_path)
.map(|path_ptr| {
let path_size = usize::from(entry.fts_pathlen).saturating_add(1);

Expand Down
2 changes: 1 addition & 1 deletion src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::FILE)
.hide(true)
.action(clap::ArgAction::Append)
.action(ArgAction::Append)
.value_parser(ValueParser::os_string())
.value_hint(clap::ValueHint::FilePath),
)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/comm/src/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ impl OrderChecker {
// Check if two files are identical by comparing their contents
pub fn are_files_identical(path1: &str, path2: &str) -> io::Result<bool> {
// First compare file sizes
let metadata1 = std::fs::metadata(path1)?;
let metadata2 = std::fs::metadata(path2)?;
let metadata1 = metadata(path1)?;
let metadata2 = metadata(path2)?;

if metadata1.len() != metadata2.len() {
return Ok(false);
Expand Down
23 changes: 10 additions & 13 deletions src/uu/cp/src/copydir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct Context<'a> {
}

impl<'a> Context<'a> {
fn new(root: &'a Path, target: &'a Path) -> std::io::Result<Self> {
fn new(root: &'a Path, target: &'a Path) -> io::Result<Self> {
let current_dir = env::current_dir()?;
let root_path = current_dir.join(root);
let root_parent = if target.exists() && !root.to_str().unwrap().ends_with("/.") {
Expand Down Expand Up @@ -181,7 +181,7 @@ impl Entry {
if no_target_dir {
let source_is_dir = source.is_dir();
if path_ends_with_terminator(context.target) && source_is_dir {
if let Err(e) = std::fs::create_dir_all(context.target) {
if let Err(e) = fs::create_dir_all(context.target) {
eprintln!("Failed to create directory: {e}");
}
} else {
Expand Down Expand Up @@ -305,9 +305,7 @@ fn copy_direntry(
false,
) {
Ok(_) => {}
Err(Error::IoErrContext(e, _))
if e.kind() == std::io::ErrorKind::PermissionDenied =>
{
Err(Error::IoErrContext(e, _)) if e.kind() == io::ErrorKind::PermissionDenied => {
show!(uio_error!(
e,
"cannot open {} for reading",
Expand Down Expand Up @@ -580,14 +578,13 @@ fn build_dir(
// we need to allow trivial casts here because some systems like linux have u32 constants in
// in libc while others don't.
#[allow(clippy::unnecessary_cast)]
let mut excluded_perms =
if matches!(options.attributes.ownership, crate::Preserve::Yes { .. }) {
libc::S_IRWXG | libc::S_IRWXO // exclude rwx for group and other
} else if matches!(options.attributes.mode, crate::Preserve::Yes { .. }) {
libc::S_IWGRP | libc::S_IWOTH //exclude w for group and other
} else {
0
} as u32;
let mut excluded_perms = if matches!(options.attributes.ownership, Preserve::Yes { .. }) {
libc::S_IRWXG | libc::S_IRWXO // exclude rwx for group and other
} else if matches!(options.attributes.mode, Preserve::Yes { .. }) {
libc::S_IWGRP | libc::S_IWOTH //exclude w for group and other
} else {
0
} as u32;

let umask = if copy_attributes_from.is_some()
&& matches!(options.attributes.mode, Preserve::Yes { .. })
Expand Down
12 changes: 6 additions & 6 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ pub fn uu_app() -> Command {
Arg::new(options::PROGRESS_BAR)
.long(options::PROGRESS_BAR)
.short('g')
.action(clap::ArgAction::SetTrue)
.action(ArgAction::SetTrue)
.help(
"Display a progress bar. \n\
Note: this feature is not supported by GNU coreutils.",
Expand Down Expand Up @@ -2081,7 +2081,7 @@ fn handle_copy_mode(
CopyMode::Update => {
if dest.exists() {
match options.update {
update_control::UpdateMode::ReplaceAll => {
UpdateMode::ReplaceAll => {
copy_helper(
source,
dest,
Expand All @@ -2094,17 +2094,17 @@ fn handle_copy_mode(
source_is_stream,
)?;
}
update_control::UpdateMode::ReplaceNone => {
UpdateMode::ReplaceNone => {
if options.debug {
println!("skipped {}", dest.quote());
}

return Ok(PerformedAction::Skipped);
}
update_control::UpdateMode::ReplaceNoneFail => {
UpdateMode::ReplaceNoneFail => {
return Err(Error::Error(format!("not replacing '{}'", dest.display())));
}
update_control::UpdateMode::ReplaceIfOlder => {
UpdateMode::ReplaceIfOlder => {
let dest_metadata = fs::symlink_metadata(dest)?;

let src_time = source_metadata.modified()?;
Expand Down Expand Up @@ -2335,7 +2335,7 @@ fn copy_file(
&FileInformation::from_path(source, options.dereference(source_in_command_line))
.context(format!("cannot stat {}", source.quote()))?,
) {
std::fs::hard_link(new_source, dest)?;
fs::hard_link(new_source, dest)?;

if options.verbose {
print_verbose_output(options.parents, progress_bar, source, dest);
Expand Down
4 changes: 2 additions & 2 deletions src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod options {

/// Command line options for csplit.
pub struct CsplitOptions {
split_name: crate::SplitName,
split_name: SplitName,
keep_files: bool,
quiet: bool,
elide_empty_files: bool,
Expand Down Expand Up @@ -661,7 +661,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::PATTERN)
.hide(true)
.action(clap::ArgAction::Append)
.action(ArgAction::Append)
.required(true),
)
.after_help(AFTER_HELP)
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cut/src/cut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
filenames.push("-".to_owned());
}

let mut out: Box<dyn Write> = if std::io::stdout().is_terminal() {
let mut out: Box<dyn Write> = if stdout().is_terminal() {
Box::new(stdout())
} else {
Box::new(BufWriter::new(stdout())) as Box<dyn Write>
Expand Down
28 changes: 14 additions & 14 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl Source {
/// The length of the data source in number of bytes.
///
/// If it cannot be determined, then this function returns 0.
fn len(&self) -> std::io::Result<i64> {
fn len(&self) -> io::Result<i64> {
match self {
Self::File(f) => Ok(f.metadata()?.len().try_into().unwrap_or(i64::MAX)),
_ => Ok(0),
Expand Down Expand Up @@ -260,7 +260,7 @@ impl Source {
Err(e) => Err(e),
}
}
Self::File(f) => f.seek(io::SeekFrom::Current(n.try_into().unwrap())),
Self::File(f) => f.seek(SeekFrom::Current(n.try_into().unwrap())),
#[cfg(unix)]
Self::Fifo(f) => io::copy(&mut f.take(n), &mut io::sink()),
}
Expand Down Expand Up @@ -470,7 +470,7 @@ impl Input<'_> {
/// Fills a given buffer.
/// Reads in increments of 'self.ibs'.
/// The start of each ibs-sized read follows the previous one.
fn fill_consecutive(&mut self, buf: &mut Vec<u8>) -> std::io::Result<ReadStat> {
fn fill_consecutive(&mut self, buf: &mut Vec<u8>) -> io::Result<ReadStat> {
let mut reads_complete = 0;
let mut reads_partial = 0;
let mut bytes_total = 0;
Expand Down Expand Up @@ -501,7 +501,7 @@ impl Input<'_> {
/// Fills a given buffer.
/// Reads in increments of 'self.ibs'.
/// The start of each ibs-sized read is aligned to multiples of ibs; remaining space is filled with the 'pad' byte.
fn fill_blocks(&mut self, buf: &mut Vec<u8>, pad: u8) -> std::io::Result<ReadStat> {
fn fill_blocks(&mut self, buf: &mut Vec<u8>, pad: u8) -> io::Result<ReadStat> {
let mut reads_complete = 0;
let mut reads_partial = 0;
let mut base_idx = 0;
Expand Down Expand Up @@ -612,7 +612,7 @@ impl Dest {
return Ok(len);
}
}
f.seek(io::SeekFrom::Current(n.try_into().unwrap()))
f.seek(SeekFrom::Current(n.try_into().unwrap()))
}
#[cfg(unix)]
Self::Fifo(f) => {
Expand Down Expand Up @@ -655,7 +655,7 @@ impl Dest {
/// The length of the data destination in number of bytes.
///
/// If it cannot be determined, then this function returns 0.
fn len(&self) -> std::io::Result<i64> {
fn len(&self) -> io::Result<i64> {
match self {
Self::File(f, _) => Ok(f.metadata()?.len().try_into().unwrap_or(i64::MAX)),
_ => Ok(0),
Expand All @@ -676,7 +676,7 @@ impl Write for Dest {
.len()
.try_into()
.expect("Internal dd Error: Seek amount greater than signed 64-bit integer");
f.seek(io::SeekFrom::Current(seek_amt))?;
f.seek(SeekFrom::Current(seek_amt))?;
Ok(buf.len())
}
Self::File(f, _) => f.write(buf),
Expand Down Expand Up @@ -893,7 +893,7 @@ impl<'a> Output<'a> {
}

/// Flush the output to disk, if configured to do so.
fn sync(&mut self) -> std::io::Result<()> {
fn sync(&mut self) -> io::Result<()> {
if self.settings.oconv.fsync {
self.dst.fsync()
} else if self.settings.oconv.fdatasync {
Expand All @@ -905,7 +905,7 @@ impl<'a> Output<'a> {
}

/// Truncate the underlying file to the current stream position, if possible.
fn truncate(&mut self) -> std::io::Result<()> {
fn truncate(&mut self) -> io::Result<()> {
self.dst.truncate()
}
}
Expand Down Expand Up @@ -959,7 +959,7 @@ impl BlockWriter<'_> {
};
}

fn write_blocks(&mut self, buf: &[u8]) -> std::io::Result<WriteStat> {
fn write_blocks(&mut self, buf: &[u8]) -> io::Result<WriteStat> {
match self {
Self::Unbuffered(o) => o.write_blocks(buf),
Self::Buffered(o) => o.write_blocks(buf),
Expand All @@ -969,7 +969,7 @@ impl BlockWriter<'_> {

/// depending on the command line arguments, this function
/// informs the OS to flush/discard the caches for input and/or output file.
fn flush_caches_full_length(i: &Input, o: &Output) -> std::io::Result<()> {
fn flush_caches_full_length(i: &Input, o: &Output) -> io::Result<()> {
// TODO Better error handling for overflowing `len`.
if i.settings.iflags.nocache {
let offset = 0;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ fn flush_caches_full_length(i: &Input, o: &Output) -> std::io::Result<()> {
///
/// If there is a problem reading from the input or writing to
/// this output.
fn dd_copy(mut i: Input, o: Output) -> std::io::Result<()> {
fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
// The read and write statistics.
//
// These objects are counters, initialized to zero. After each
Expand Down Expand Up @@ -1177,7 +1177,7 @@ fn finalize<T>(
prog_tx: &mpsc::Sender<ProgUpdate>,
output_thread: thread::JoinHandle<T>,
truncate: bool,
) -> std::io::Result<()> {
) -> io::Result<()> {
// Flush the output in case a partial write has been buffered but
// not yet written.
let wstat_update = output.flush()?;
Expand Down Expand Up @@ -1245,7 +1245,7 @@ fn make_linux_oflags(oflags: &OFlags) -> Option<libc::c_int> {
/// `conv=swab` or `conv=block` command-line arguments. This function
/// mutates the `buf` argument in-place. The returned [`ReadStat`]
/// indicates how many blocks were read.
fn read_helper(i: &mut Input, buf: &mut Vec<u8>, bsize: usize) -> std::io::Result<ReadStat> {
fn read_helper(i: &mut Input, buf: &mut Vec<u8>, bsize: usize) -> io::Result<ReadStat> {
// Local Helper Fns -------------------------------------------------
fn perform_swab(buf: &mut [u8]) {
for base in (1..buf.len()).step_by(2) {
Expand Down
Loading
Loading