Skip to content

Commit a576054

Browse files
committed
fuzz: fix clippy warnings
1 parent e6f9e35 commit a576054

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

fuzz/fuzz_targets/fuzz_common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn is_gnu_cmd(cmd_path: &str) -> Result<(), std::io::Error> {
3232
}
3333
}
3434

35-
pub fn generate_and_run_uumain<F>(args: &mut Vec<OsString>, uumain_function: F) -> (String, i32)
35+
pub fn generate_and_run_uumain<F>(args: &[OsString], uumain_function: F) -> (String, i32)
3636
where
3737
F: FnOnce(std::vec::IntoIter<OsString>) -> i32,
3838
{
@@ -45,7 +45,7 @@ where
4545

4646
{
4747
unsafe { dup2(pipe_fds[1], STDOUT_FILENO) };
48-
uumain_exit_status = uumain_function(args.clone().into_iter());
48+
uumain_exit_status = uumain_function(args.to_owned().into_iter());
4949
unsafe { dup2(original_stdout_fd, STDOUT_FILENO) };
5050
unsafe { libc::close(original_stdout_fd) };
5151
}

fuzz/fuzz_targets/fuzz_date.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ fuzz_target!(|data: &[u8]| {
99
let args = data
1010
.split(|b| *b == delim)
1111
.filter_map(|e| std::str::from_utf8(e).ok())
12-
.map(|e| OsString::from(e));
12+
.map(OsString::from);
1313
uumain(args);
1414
});

fuzz/fuzz_targets/fuzz_expr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fuzz_target!(|_data: &[u8]| {
8484
let mut args = vec![OsString::from("expr")];
8585
args.extend(expr.split_whitespace().map(OsString::from));
8686

87-
let (rust_output, uumain_exit_code) = generate_and_run_uumain(&mut args, uumain);
87+
let (rust_output, uumain_exit_code) = generate_and_run_uumain(&args, uumain);
8888

8989
// Run GNU expr with the provided arguments and compare the output
9090
match run_gnu_cmd(CMD_PATH, &args[1..], true) {
@@ -96,16 +96,16 @@ fuzz_target!(|_data: &[u8]| {
9696
println!("GNU code: {}", gnu_exit_code);
9797
panic!("Different error codes");
9898
}
99-
if rust_output != gnu_output {
100-
println!("Expression: {}", expr);
101-
println!("Rust output: {}", rust_output);
102-
println!("GNU output: {}", gnu_output);
103-
panic!("Different output between Rust & GNU");
104-
} else {
99+
if rust_output == gnu_output {
105100
println!(
106101
"Outputs matched for expression: {} => Result: {}",
107102
expr, rust_output
108103
);
104+
} else {
105+
println!("Expression: {}", expr);
106+
println!("Rust output: {}", rust_output);
107+
println!("GNU output: {}", gnu_output);
108+
panic!("Different output between Rust & GNU");
109109
}
110110
}
111111
Err(_) => {

fuzz/fuzz_targets/fuzz_parse_glob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ use uucore::parse_glob;
55

66
fuzz_target!(|data: &[u8]| {
77
if let Ok(s) = std::str::from_utf8(data) {
8-
_ = parse_glob::from_str(s)
8+
_ = parse_glob::from_str(s);
99
}
1010
});

fuzz/fuzz_targets/fuzz_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn generate_test_arg() -> String {
142142
0 => {
143143
arg.push_str(&rng.gen_range(-100..=100).to_string());
144144
}
145-
1 | 2 | 3 => {
145+
1..=3 => {
146146
let test_arg = test_args
147147
.choose(&mut rng)
148148
.expect("Failed to choose a random test argument");
@@ -204,7 +204,7 @@ fuzz_target!(|_data: &[u8]| {
204204
args.push(OsString::from(generate_test_arg()));
205205
}
206206

207-
let (rust_output, uumain_exit_status) = generate_and_run_uumain(&mut args, uumain);
207+
let (rust_output, uumain_exit_status) = generate_and_run_uumain(&args, uumain);
208208

209209
// Run GNU test with the provided arguments and compare the output
210210
match run_gnu_cmd(CMD_PATH, &args[1..], false) {

0 commit comments

Comments
 (0)