diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 9953c064f..c1e66d44c 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -537,33 +537,29 @@ fn process_file( let mut result = Ok(()); match entry.flags() { - fts_sys::FTS_D => { - if options.recursive_mode.is_recursive() { - if root_dev_ino_check(root_dev_ino, file_dev_ino) { - // This happens e.g., with "chcon -R --preserve-root ... /" - // and with "chcon -RH --preserve-root ... symlink-to-root". - root_dev_ino_warn(&file_full_name); + fts_sys::FTS_D if options.recursive_mode.is_recursive() => { + if root_dev_ino_check(root_dev_ino, file_dev_ino) { + // This happens e.g., with "chcon -R --preserve-root ... /" + // and with "chcon -RH --preserve-root ... symlink-to-root". + root_dev_ino_warn(&file_full_name); - // Tell fts not to traverse into this hierarchy. - let _ignored = fts.set(fts_sys::FTS_SKIP); + // Tell fts not to traverse into this hierarchy. + let _ignored = fts.set(fts_sys::FTS_SKIP); - // Ensure that we do not process "/" on the second visit. - let _ignored = fts.read_next_entry(); + // Ensure that we do not process "/" on the second visit. + let _ignored = fts.read_next_entry(); - return Err(err( - translate!("chcon-op-modifying-root-path"), - io::ErrorKind::PermissionDenied, - )); - } - - return Ok(()); + return Err(err( + translate!("chcon-op-modifying-root-path"), + io::ErrorKind::PermissionDenied, + )); } + + return Ok(()); } - fts_sys::FTS_DP => { - if !options.recursive_mode.is_recursive() { - return Ok(()); - } + fts_sys::FTS_DP if !options.recursive_mode.is_recursive() => { + return Ok(()); } fts_sys::FTS_NS => { @@ -585,14 +581,14 @@ fn process_file( fts_sys::FTS_DNR => result = fts_err(translate!("chcon-op-reading-directory")), - fts_sys::FTS_DC => { - if cycle_warning_required(options.recursive_mode.fts_open_options(), &entry) { - emit_cycle_warning(&file_full_name); - return Err(err( - translate!("chcon-op-reading-cyclic-directory"), - io::ErrorKind::InvalidData, - )); - } + fts_sys::FTS_DC + if cycle_warning_required(options.recursive_mode.fts_open_options(), &entry) => + { + emit_cycle_warning(&file_full_name); + return Err(err( + translate!("chcon-op-reading-cyclic-directory"), + io::ErrorKind::InvalidData, + )); } _ => {} diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 9f023a393..2e9ae6b62 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1134,10 +1134,8 @@ impl Options { options::PRESERVE => { attributes = attributes.union(&Attributes::parse_iter(val.into_iter())?); } - options::NO_PRESERVE => { - if !val.is_empty() { - attributes = attributes.diff(&Attributes::parse_iter(val.into_iter())?); - } + options::NO_PRESERVE if !val.is_empty() => { + attributes = attributes.diff(&Attributes::parse_iter(val.into_iter())?); } _ => (), } diff --git a/src/uu/date/src/format_modifiers.rs b/src/uu/date/src/format_modifiers.rs index fd269379a..bd87f4647 100644 --- a/src/uu/date/src/format_modifiers.rs +++ b/src/uu/date/src/format_modifiers.rs @@ -379,11 +379,9 @@ fn apply_modifiers(value: &str, parsed: &ParsedSpec<'_>) -> Result { - if !uppercase { - // Only apply # if ^ hasn't been set - swap_case = true; - } + '#' if !uppercase => { + // Only apply # if ^ hasn't been set + swap_case = true; } '+' => { force_sign = true; diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 1a16b9276..7762048ea 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -132,38 +132,35 @@ impl OdOptions { let formats = parse_format_flags(args).map_err(|e| USimpleError::new(1, e))?; - let mut line_bytes = match matches.get_one::(options::WIDTH) { - None => 16, - Some(s) => { - if matches.value_source(options::WIDTH) == Some(ValueSource::CommandLine) { - let width_display = option_display_name(args, options::WIDTH, Some('w')); - let parsed = parse_number_of_bytes(s).map_err(|e| { - USimpleError::new(1, format_error_message(&e, s, &width_display)) - })?; - if parsed == 0 { - return Err(USimpleError::new( - 1, - translate!( - "od-error-invalid-argument", - "option" => width_display.clone(), - "value" => s.quote() - ), - )); - } - usize::try_from(parsed).map_err(|_| { - USimpleError::new( - 1, - translate!( - "od-error-argument-too-large", - "option" => width_display.clone(), - "value" => s.quote() - ), - ) - })? - } else { - 16 - } + let mut line_bytes = if let (Some(s), Some(ValueSource::CommandLine)) = ( + matches.get_one::(options::WIDTH), + matches.value_source(options::WIDTH), + ) { + let width_display = option_display_name(args, options::WIDTH, Some('w')); + let parsed = parse_number_of_bytes(s) + .map_err(|e| USimpleError::new(1, format_error_message(&e, s, &width_display)))?; + if parsed == 0 { + return Err(USimpleError::new( + 1, + translate!( + "od-error-invalid-argument", + "option" => width_display.clone(), + "value" => s.quote() + ), + )); } + usize::try_from(parsed).map_err(|_| { + USimpleError::new( + 1, + translate!( + "od-error-argument-too-large", + "option" => width_display.clone(), + "value" => s.quote() + ), + ) + })? + } else { + 16 }; let min_bytes = formats.iter().fold(1, |max, next| { diff --git a/src/uu/tail/src/follow/watch.rs b/src/uu/tail/src/follow/watch.rs index c38f2d081..7300e9540 100644 --- a/src/uu/tail/src/follow/watch.rs +++ b/src/uu/tail/src/follow/watch.rs @@ -439,7 +439,7 @@ impl Observer { */ } } - EventKind::Modify(ModifyKind::Name(RenameMode::Both)) => { + EventKind::Modify(ModifyKind::Name(RenameMode::Both)) /* NOTE: For `tail -f a`, keep tracking additions to b after `mv a b` (gnu/tests/tail-2/descriptor-vs-rename.sh) @@ -457,7 +457,7 @@ impl Observer { TODO: [2022-05; jhscheer] add test for this bug */ - if self.follow_descriptor() { + if self.follow_descriptor() => { let new_path = event.paths.last().unwrap(); paths.push(new_path.clone()); @@ -472,7 +472,6 @@ impl Observer { let _ = self.watcher_rx.as_mut().unwrap().unwatch(event_path); self.watcher_rx.as_mut().unwrap().watch_with_parent(new_path)?; } - } _ => {} } Ok(paths) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 0f2b37dc1..d165b8a9f 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -435,12 +435,11 @@ pub fn canonicalize>( } result.pop(); } - Err(e) => { - if miss_mode == MissingHandling::Existing - || (miss_mode == MissingHandling::Normal && !parts.is_empty()) - { - return Err(e); - } + Err(e) + if (miss_mode == MissingHandling::Existing + || (miss_mode == MissingHandling::Normal && !parts.is_empty())) => + { + return Err(e); } _ => {} }