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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ ignored_unit_patterns = "allow" # 21
similar_names = "allow" # 20
large_stack_arrays = "allow" # 20
wildcard_imports = "allow" # 18
used_underscore_binding = "allow" # 18
needless_pass_by_value = "allow" # 16
float_cmp = "allow" # 12
items_after_statements = "allow" # 11
Expand Down
6 changes: 3 additions & 3 deletions src/uu/df/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
impl Filesystem {
// TODO: resolve uuid in `mount_info.dev_name` if exists
pub(crate) fn new(mount_info: MountInfo, file: Option<OsString>) -> Option<Self> {
let _stat_path = if mount_info.mount_dir.is_empty() {
let stat_path = if mount_info.mount_dir.is_empty() {
#[cfg(unix)]
{
mount_info.dev_name.clone().into()
Expand All @@ -135,9 +135,9 @@ impl Filesystem {
mount_info.mount_dir.clone()
};
#[cfg(unix)]
let usage = FsUsage::new(statfs(&_stat_path).ok()?);
let usage = FsUsage::new(statfs(&stat_path).ok()?);
#[cfg(windows)]
let usage = FsUsage::new(Path::new(&_stat_path)).ok()?;
let usage = FsUsage::new(Path::new(&stat_path)).ok()?;
Some(Self {
file,
mount_info,
Expand Down
28 changes: 13 additions & 15 deletions src/uu/env/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,27 +749,25 @@ impl EnvAppData {
do_debug_printing: bool,
) -> Result<(), Box<dyn UError>> {
let prog = Cow::from(opts.program[0]);
#[cfg(unix)]
let mut arg0 = prog.clone();
#[cfg(not(unix))]
let arg0 = prog.clone();
let args = &opts.program[1..];

if let Some(_argv0) = opts.argv0 {
#[cfg(unix)]
{
arg0 = Cow::Borrowed(_argv0);
let arg0 = match opts.argv0 {
None => prog.clone(),
Some(argv0) if cfg!(unix) => {
let arg0 = Cow::Borrowed(argv0);
if do_debug_printing {
eprintln!("argv0: {}", arg0.quote());
}
arg0
}
Some(_) => {
return Err(USimpleError::new(
2,
translate!("env-error-argv0-not-supported"),
));
}
};

#[cfg(not(unix))]
return Err(USimpleError::new(
2,
translate!("env-error-argv0-not-supported"),
));
}
let args = &opts.program[1..];

if do_debug_printing {
eprintln!("executing: {}", prog.maybe_quote());
Expand Down
8 changes: 1 addition & 7 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ fn copy_dir_contents(
}
#[cfg(not(unix))]
{
copy_dir_contents_recursive(from, to, None, None, verbose, progress_bar, display_manager)?;
copy_dir_contents_recursive(from, to, verbose, progress_bar, display_manager)?;
}

Ok(())
Expand All @@ -1038,8 +1038,6 @@ fn copy_dir_contents_recursive(
to_dir: &Path,
#[cfg(unix)] hardlink_tracker: &mut HardlinkTracker,
#[cfg(unix)] hardlink_scanner: &HardlinkGroupScanner,
#[cfg(not(unix))] _hardlink_tracker: Option<()>,
#[cfg(not(unix))] _hardlink_scanner: Option<()>,
verbose: bool,
progress_bar: Option<&ProgressBar>,
display_manager: Option<&MultiProgress>,
Expand Down Expand Up @@ -1078,10 +1076,6 @@ fn copy_dir_contents_recursive(
hardlink_tracker,
#[cfg(unix)]
hardlink_scanner,
#[cfg(not(unix))]
_hardlink_tracker,
#[cfg(not(unix))]
_hardlink_scanner,
verbose,
progress_bar,
display_manager,
Expand Down
14 changes: 7 additions & 7 deletions src/uu/split/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ impl Write for FilterWriter {
/// Have an environment variable set at a value during this lifetime
struct WithEnvVarSet {
/// Env var key
_previous_var_key: String,
previous_var_key: String,
/// Previous value set to this key
_previous_var_value: std::result::Result<String, env::VarError>,
previous_var_value: std::result::Result<String, env::VarError>,
}
impl WithEnvVarSet {
/// Save previous value assigned to key, set key=value
Expand All @@ -55,22 +55,22 @@ impl WithEnvVarSet {
env::set_var(key, value);
}
Self {
_previous_var_key: String::from(key),
_previous_var_value: previous_env_value,
previous_var_key: String::from(key),
previous_var_value: previous_env_value,
}
}
}

impl Drop for WithEnvVarSet {
/// Restore previous value now that this is being dropped by context
fn drop(&mut self) {
if let Ok(ref prev_value) = self._previous_var_value {
if let Ok(ref prev_value) = self.previous_var_value {
unsafe {
env::set_var(&self._previous_var_key, prev_value);
env::set_var(&self.previous_var_key, prev_value);
}
} else {
unsafe {
env::remove_var(&self._previous_var_key);
env::remove_var(&self.previous_var_key);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/uu/stat/src/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ impl Stater {
file: &OsString,
file_type: &FileType,
from_user: bool,
_follow_symbolic_links: bool,
#[cfg(feature = "selinux")] follow_symbolic_links: bool,
#[cfg(not(feature = "selinux"))] _: bool,
) -> Result<(), i32> {
match *t {
Token::Byte(byte) => write_raw_byte(byte),
Expand Down Expand Up @@ -1035,7 +1036,7 @@ impl Stater {
if uucore::selinux::is_selinux_enabled() {
match uucore::selinux::get_selinux_security_context(
Path::new(file),
_follow_symbolic_links,
follow_symbolic_links,
) {
Ok(ctx) => OutputType::Str(ctx),
Err(_) => OutputType::Str(translate!(
Expand Down
8 changes: 6 additions & 2 deletions src/uu/stty/src/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,15 @@ fn apply_special_setting(
match setting {
SpecialSetting::Rows(n) => size.rows = *n,
SpecialSetting::Cols(n) => size.columns = *n,
SpecialSetting::Line(_n) => {
#[cfg_attr(
not(any(target_os = "linux", target_os = "android")),
expect(unused_variables)
)]
SpecialSetting::Line(n) => {
// nix only defines Termios's `line_discipline` field on these platforms
#[cfg(any(target_os = "linux", target_os = "android"))]
{
_termios.line_discipline = *_n;
_termios.line_discipline = *n;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/uu/tail/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ impl MetadataExtTail for Metadata {
Ok(other.len() < self.len() && other.modified()? != self.modified()?)
}

fn file_id_eq(&self, _other: &Metadata) -> bool {
fn file_id_eq(&self, #[cfg(unix)] other: &Metadata, #[cfg(not(unix))] _: &Metadata) -> bool {
#[cfg(unix)]
{
self.ino().eq(&_other.ino())
self.ino().eq(&other.ino())
}
#[cfg(windows)]
{
Expand Down
11 changes: 4 additions & 7 deletions src/uu/who/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,10 @@ fn current_tty() -> String {
impl Who {
#[allow(clippy::cognitive_complexity)]
fn exec(&mut self) -> UResult<()> {
let run_level_chk = |_record: i16| {
#[cfg(not(target_os = "linux"))]
return false;

#[cfg(target_os = "linux")]
return _record == utmpx::RUN_LVL;
};
#[cfg(target_os = "linux")]
let run_level_chk = |record: i16| record == utmpx::RUN_LVL;
#[cfg(not(target_os = "linux"))]
let run_level_chk = |_| false;

let f = if self.args.len() == 1 {
self.args[0].as_ref()
Expand Down
7 changes: 5 additions & 2 deletions src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,13 @@ pub mod sane_blksize {
///
/// If the metadata contain invalid values a meaningful adaption
/// of that value is done.
pub fn sane_blksize_from_metadata(_metadata: &std::fs::Metadata) -> u64 {
pub fn sane_blksize_from_metadata(
#[cfg(unix)] metadata: &std::fs::Metadata,
#[cfg(not(unix))] _: &std::fs::Metadata,
) -> u64 {
#[cfg(not(target_os = "windows"))]
{
sane_blksize(_metadata.blksize())
sane_blksize(metadata.blksize())
}

#[cfg(target_os = "windows")]
Expand Down
8 changes: 4 additions & 4 deletions src/uucore/src/lib/features/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ impl Digest for Bsd {
}

fn result(&mut self) -> DigestOutput {
let mut _out = [0; 2];
self.hash_finalize(&mut _out);
let mut out = [0; 2];
self.hash_finalize(&mut out);
DigestOutput::U16(self.state)
}

Expand Down Expand Up @@ -319,8 +319,8 @@ impl Digest for SysV {
}

fn result(&mut self) -> DigestOutput {
let mut _out = [0; 2];
self.hash_finalize(&mut _out);
let mut out = [0; 2];
self.hash_finalize(&mut out);
DigestOutput::U16((self.state & (u16::MAX as u32)) as u16)
}

Expand Down
Loading