Fixes for new Clippy (#755)

This commit is contained in:
Dominik Maier 2022-09-02 16:21:06 +02:00 committed by GitHub
parent c4e0faabc2
commit 5823320206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 18 deletions

View File

@ -154,9 +154,9 @@ mod test {
#[test]
fn test_atomic_file_write() {
let path = "test_atomic_file_write.tmp";
write_file_atomic(&path, b"test").unwrap();
let content = fs::read_to_string(&path).unwrap();
fs::remove_file(&path).unwrap();
write_file_atomic(path, b"test").unwrap();
let content = fs::read_to_string(path).unwrap();
fs::remove_file(path).unwrap();
assert_eq!(content, "test");
}

View File

@ -14,7 +14,6 @@ use core::{mem::ManuallyDrop, ptr::addr_of};
#[cfg(target_vendor = "apple")]
use std::fs;
use std::{
borrow::BorrowMut,
cell::RefCell,
env,
io::{Read, Write},
@ -225,8 +224,8 @@ where
fn post_fork(&mut self, is_child: bool) -> Result<(), Error> {
if is_child {
// After fork, only the parent keeps the join handle.
if let ShMemService::Started { bg_thread, .. } = &mut self.service {
bg_thread.borrow_mut().lock().unwrap().join_handle = None;
if let ShMemService::Started { bg_thread, .. } = &self.service {
bg_thread.lock().unwrap().join_handle = None;
}
//fn connect(&mut self) -> Result<Self, Error> {
//self.stream = UnixStream::connect_to_unix_addr(&UnixSocketAddr::new(UNIX_SERVER_NAME)?)?,
@ -371,7 +370,7 @@ impl Drop for ShMemServiceThread {
.expect("Error in ShMemService background thread!");
// try to remove the file from fs, and ignore errors.
#[cfg(target_vendor = "apple")]
fs::remove_file(&UNIX_SERVER_NAME).unwrap();
fs::remove_file(UNIX_SERVER_NAME).unwrap();
env::remove_var(AFL_SHMEM_SERVICE_STARTED);
}

View File

@ -9,8 +9,6 @@ pub mod tui;
#[cfg(feature = "std")]
pub mod disk;
#[cfg(feature = "introspection")]
use alloc::string::ToString;
use alloc::{fmt::Debug, string::String, vec::Vec};
use core::{fmt, time::Duration};
@ -346,7 +344,7 @@ where
(self.print_fn)(fmt);
// Separate the spacing just a bit
(self.print_fn)("".to_string());
(self.print_fn)(String::new());
}
}
}

View File

@ -623,7 +623,7 @@ token1="A\x41A"
token2="B"
"###;
fs::write("test.tkns", data).expect("Unable to write test.tkns");
let tokens = Tokens::from_file(&"test.tkns").unwrap();
let tokens = Tokens::from_file("test.tkns").unwrap();
#[cfg(feature = "std")]
println!("Token file entries: {:?}", tokens.tokens());
assert_eq!(tokens.tokens().len(), 2);

View File

@ -436,7 +436,7 @@ where
manager,
in_dir,
forced,
&mut |_, _, path| I::from_file(&path),
&mut |_, _, path| I::from_file(path),
)?;
}
manager.fire(

View File

@ -92,7 +92,7 @@ fn exec_llvm_config(args: &[&str]) -> String {
/// Use `xcrun` to get the path to the Xcode SDK tools library path, for linking
fn find_macos_sdk_libs() -> String {
let sdk_path_out = Command::new("xcrun")
.args(&["--show-sdk-path"])
.arg("--show-sdk-path")
.output()
.expect("Failed to execute xcrun. Make sure you have Xcode installed and executed `sudo xcode-select --install`");
format!(
@ -129,7 +129,7 @@ fn build_pass(
.args(cxxflags)
.arg(src_dir.join(src_file))
.args(ldflags)
.args(&["-o"])
.arg("-o")
.arg(out_dir.join(format!("{}.{}", src_stub, dll_extension())))
.status()
.unwrap_or_else(|_| panic!("Failed to compile {}", src_file))

View File

@ -377,7 +377,7 @@ impl ClangWrapper {
optimize: true,
wrapped_cc: CLANG_PATH.into(),
wrapped_cxx: CLANGXX_PATH.into(),
name: "".into(),
name: String::new(),
is_cpp: false,
linking: false,
shared: false,

View File

@ -27,11 +27,11 @@ mod clone {
);
let mut cmd = Command::new("git");
cmd.arg("clone").arg(url).arg(&path);
cmd.arg("clone").arg(url).arg(path);
let output = cmd.output().expect("failed to execute git clone");
if output.status.success() {
let mut cmd = Command::new("git");
cmd.arg("checkout").arg(commit).current_dir(&path);
cmd.arg("checkout").arg(commit).current_dir(path);
let output = cmd.output().expect("failed to execute git checkout");
if !output.status.success() {
println!("failed to checkout symcc git repository commit:");

View File

@ -97,7 +97,7 @@ fn main() {
std::env::set_var(EXPRESSION_PRUNING, "1");
}
let res = Command::new(&opt.program.first().expect("no program argument given"))
let res = Command::new(opt.program.first().expect("no program argument given"))
.args(opt.program.iter().skip(1))
.status()
.expect("failed to spawn program");