1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #6505 from Its-Just-Nans/fix-clippy-errors

Fix clippy errors
This commit is contained in:
Sylvestre Ledru 2024-06-30 18:55:51 +02:00 committed by GitHub
commit 9c0f2f84ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1341 additions and 901 deletions

View file

@ -2328,9 +2328,9 @@ fn test_closes_file_descriptors() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_cp_sparse_never_empty() {
const BUFFER_SIZE: usize = 4096 * 4;
let (at, mut ucmd) = at_and_ucmd!();
const BUFFER_SIZE: usize = 4096 * 4;
let buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
at.make_file("src_file1");
@ -2348,10 +2348,10 @@ fn test_cp_sparse_never_empty() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_cp_sparse_always_empty() {
const BUFFER_SIZE: usize = 4096 * 4;
for argument in ["--sparse=always", "--sparse=alway", "--sparse=al"] {
let (at, mut ucmd) = at_and_ucmd!();
const BUFFER_SIZE: usize = 4096 * 4;
let buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
at.make_file("src_file1");
@ -2368,9 +2368,9 @@ fn test_cp_sparse_always_empty() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_cp_sparse_always_non_empty() {
const BUFFER_SIZE: usize = 4096 * 16 + 3;
let (at, mut ucmd) = at_and_ucmd!();
const BUFFER_SIZE: usize = 4096 * 16 + 3;
let mut buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
let blocks_to_touch = [buf.len() / 3, 2 * (buf.len() / 3)];
@ -2438,12 +2438,11 @@ fn test_cp_sparse_never_reflink_always() {
#[cfg(feature = "truncate")]
#[test]
fn test_cp_reflink_always_override() {
let scene = TestScenario::new(util_name!());
const DISK: &str = "disk.img";
const ROOTDIR: &str = "disk_root/";
const USERDIR: &str = "dir/";
const MOUNTPOINT: &str = "mountpoint/";
let scene = TestScenario::new(util_name!());
let src1_path: &str = &[MOUNTPOINT, USERDIR, "src1"].concat();
let src2_path: &str = &[MOUNTPOINT, USERDIR, "src2"].concat();
@ -2575,12 +2574,12 @@ fn test_no_preserve_mode() {
let umask: u16 = 0o022;
ucmd.arg("file")
.arg("dest")
.umask(umask as libc::mode_t)
.umask(libc::mode_t::from(umask))
.succeeds()
.no_stderr()
.no_stdout();
// remove sticky bit, setuid and setgid bit; apply umask
let expected_perms = PERMS_ALL & !0o7000 & !umask as u32;
let expected_perms = PERMS_ALL & !0o7000 & u32::from(!umask);
assert_eq!(
at.plus("dest").metadata().unwrap().mode() & 0o7777,
expected_perms
@ -5507,16 +5506,17 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
let start_time = std::time::Instant::now();
// wait for cp to create dirs
loop {
if start_time.elapsed() >= timeout {
panic!("timed out: cp took too long to create destination directory")
}
assert!(
start_time.elapsed() < timeout,
"timed out: cp took too long to create destination directory"
);
if at.dir_exists(&format!("{}/{}", DEST_DIR, SRC_DIR)) {
break;
}
std::thread::sleep(Duration::from_millis(100));
}
let mode = at.metadata(&format!("{}/{}", DEST_DIR, SRC_DIR)).mode();
#[allow(clippy::unnecessary_cast)]
#[allow(clippy::unnecessary_cast, clippy::cast_lossless)]
let mask = if attr == "mode" {
libc::S_IWGRP | libc::S_IWOTH
} else {