address upcoming clippy warnings (#1089)

This commit is contained in:
bmc-msft
2021-07-20 13:19:50 -04:00
committed by GitHub
parent 77aaa5b88c
commit 9c30183036
23 changed files with 48 additions and 51 deletions

View File

@ -273,7 +273,7 @@ impl Images {
}
if image.region().contains(&va) {
return Some(&image);
return Some(image);
}
}

View File

@ -38,7 +38,7 @@ fn print_version(include_sha: bool, include_local: bool, sha: &str) -> Result<()
if include_sha {
version.push('-');
version.push_str(&sha);
version.push_str(sha);
// if we're a non-release build, check to see if git has
// unstaged changes

View File

@ -138,7 +138,7 @@ pub fn args(name: &'static str) -> App<'static, 'static> {
let mut used = HashSet::new();
for args in &[
for args in [
build_fuzz_args(),
build_crash_args(),
build_analysis_args(false),

View File

@ -24,7 +24,7 @@ pub async fn run(args: &clap::ArgMatches<'_>, event_sender: Option<Sender<UiEven
let check_retry_count = value_t!(args, CHECK_RETRY_COUNT, u64)?;
let config = TestInputArgs {
target_exe: &target_exe.as_path(),
target_exe: target_exe.as_path(),
target_env: &target_env,
target_options: &target_options,
input_url: None,

View File

@ -55,7 +55,7 @@ pub fn args(name: &'static str) -> App<'static, 'static> {
let mut app = SubCommand::with_name(name).about("run a local generator & crash reporting job");
let mut used = HashSet::new();
for args in &[build_fuzz_args(), build_crash_args()] {
for args in [build_fuzz_args(), build_crash_args()] {
for arg in args {
if used.contains(arg.b.name) {
continue;

View File

@ -27,7 +27,7 @@ pub async fn run(args: &clap::ArgMatches<'_>, event_sender: Option<Sender<UiEven
let check_debugger = !args.is_present(DISABLE_CHECK_DEBUGGER);
let config = TestInputArgs {
target_exe: &target_exe.as_path(),
target_exe: target_exe.as_path(),
target_env: &target_env,
target_options: &target_options,
input_url: None,

View File

@ -118,7 +118,7 @@ async fn run_existing(config: &Config, reports_dir: &Option<PathBuf>) -> Result<
let mut read_dir = fs::read_dir(&crashes.local_path).await?;
while let Some(file) = read_dir.next_entry().await? {
debug!("Processing file {:?}", file);
run_tool(file.path(), &config, &reports_dir).await?;
run_tool(file.path(), config, reports_dir).await?;
count += 1;
// sync the analysis container after every 10 inputs
@ -158,10 +158,10 @@ async fn poll_inputs(
let input_url = message
.parse(|data| BlobUrl::parse(str::from_utf8(data)?))
.with_context(|| format!("unable to parse URL from queue: {:?}", message))?;
if !already_checked(&config, &input_url).await? {
if !already_checked(config, &input_url).await? {
let destination_path = _copy(input_url, &tmp_dir).await?;
run_tool(destination_path, &config, &reports_dir).await?;
run_tool(destination_path, config, reports_dir).await?;
config.analysis.sync_push().await?
}
message.delete().await?;
@ -206,13 +206,13 @@ pub async fn run_tool(
.job_id(&config.common.job_id)
.task_id(&config.common.task_id)
.set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| {
tester.microsoft_telemetry_key(&key)
tester.microsoft_telemetry_key(key)
})
.set_optional_ref(&config.common.instance_telemetry_key, |tester, key| {
tester.instance_telemetry_key(&key)
tester.instance_telemetry_key(key)
})
.set_optional_ref(&reports_dir, |tester, reports_dir| {
tester.reports_dir(&reports_dir)
.set_optional_ref(reports_dir, |tester, reports_dir| {
tester.reports_dir(reports_dir)
})
.set_optional_ref(&config.crashes, |tester, crashes| {
tester

View File

@ -164,10 +164,10 @@ impl GeneratorTask {
.task_id(&self.config.common.task_id)
.set_optional_ref(
&self.config.common.microsoft_telemetry_key,
|tester, key| tester.microsoft_telemetry_key(&key),
|tester, key| tester.microsoft_telemetry_key(key),
)
.set_optional_ref(&self.config.common.instance_telemetry_key, |tester, key| {
tester.instance_telemetry_key(&key)
tester.instance_telemetry_key(key)
})
.set_optional_ref(&self.config.tools, |expand, tools| {
expand.tools_dir(&tools.local_path)

View File

@ -179,7 +179,7 @@ async fn start_supervisor(
.runtime_dir(&runtime_dir)
.crashes(&crashes.local_path)
.input_corpus(&inputs.local_path)
.reports_dir(&reports_dir)
.reports_dir(reports_dir)
.setup_dir(&config.common.setup_dir)
.job_id(&config.common.job_id)
.task_id(&config.common.task_id)
@ -196,10 +196,10 @@ async fn start_supervisor(
expand.target_options(target_options)
})
.set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| {
tester.microsoft_telemetry_key(&key)
tester.microsoft_telemetry_key(key)
})
.set_optional_ref(&config.common.instance_telemetry_key, |tester, key| {
tester.instance_telemetry_key(&key)
tester.instance_telemetry_key(key)
})
.set_optional_ref(
&config.crashes.remote_path.clone().and_then(|u| u.account()),

View File

@ -143,10 +143,10 @@ async fn merge(config: &Config, output_dir: impl AsRef<Path>) -> Result<()> {
.job_id(&config.common.job_id)
.task_id(&config.common.task_id)
.set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| {
tester.microsoft_telemetry_key(&key)
tester.microsoft_telemetry_key(key)
})
.set_optional_ref(&config.common.instance_telemetry_key, |tester, key| {
tester.instance_telemetry_key(&key)
tester.instance_telemetry_key(key)
});
let supervisor_path = expand.evaluate_value(&config.supervisor_exe)?;

View File

@ -40,7 +40,7 @@ pub async fn run(
crashes,
report_dirs,
report_list,
&regression_reports,
regression_reports,
&heartbeat_client,
)
.await
@ -50,7 +50,7 @@ pub async fn run(
handle_inputs(
handler,
readonly_inputs,
&regression_reports,
regression_reports,
&heartbeat_client,
)
.await

View File

@ -73,7 +73,7 @@ impl ReportTask {
info!("processing existing crashes");
if let Some(crashes) = &self.config.crashes {
self.poller.batch_process(&mut processor, &crashes).await?;
self.poller.batch_process(&mut processor, crashes).await?;
}
info!("processing crashes from queue");

View File

@ -89,7 +89,7 @@ impl ReportTask {
let mut processor = AsanProcessor::new(self.config.clone()).await?;
if let Some(crashes) = &self.config.crashes {
self.poller.batch_process(&mut processor, &crashes).await?;
self.poller.batch_process(&mut processor, crashes).await?;
}
if self.config.check_queue {

View File

@ -38,7 +38,7 @@ fn print_version(include_sha: bool, include_local: bool, sha: &str) -> Result<()
if include_sha {
version.push('-');
version.push_str(&sha);
version.push_str(sha);
// if we're a non-release build, check to see if git has
// unstaged changes

View File

@ -14,7 +14,7 @@ pub fn set_panic_handler() {
SET_HOOK.call_once(move || {
let old_hook = panic::take_hook();
panic::set_hook(Box::new(move |info| {
panic_hook(&info);
panic_hook(info);
old_hook(info);
}));
});

View File

@ -325,7 +325,7 @@ impl<'a> Expand<'a> {
Ok(arg)
}
ExpandedValue::Scalar(v) => {
arg = arg.replace(fmtstr, &v);
arg = arg.replace(fmtstr, v);
Ok(arg)
}
ExpandedValue::List(value) => {
@ -335,7 +335,7 @@ impl<'a> Expand<'a> {
Ok(arg)
}
ExpandedValue::Mapping(func) => {
if let Some(value) = func(self, &fmtstr) {
if let Some(value) = func(self, fmtstr) {
let arg = self.replace_value(fmtstr, arg, &value)?;
Ok(arg)
} else {

View File

@ -302,10 +302,10 @@ impl<'a> Tester<'a> {
let expand = Expand::new()
.input_path(input_file)
.target_exe(&self.exe_path)
.target_options(&self.arguments)
.target_options(self.arguments)
.setup_dir(&self.setup_dir);
let argv = expand.evaluate(&self.arguments)?;
let argv = expand.evaluate(self.arguments)?;
let mut env: HashMap<String, String> = HashMap::new();
for (k, v) in self.environ {
env.insert(k.clone(), expand.evaluate_value(v)?);
@ -314,15 +314,15 @@ impl<'a> Tester<'a> {
let setup_dir = &self.setup_dir.to_path_buf();
if self.add_setup_to_path {
let new_path = match env.get(PATH) {
Some(v) => update_path(v.clone().into(), &setup_dir)?,
None => get_path_with_directory(PATH, &setup_dir)?,
Some(v) => update_path(v.clone().into(), setup_dir)?,
None => get_path_with_directory(PATH, setup_dir)?,
};
env.insert(PATH.to_string(), new_path.to_string_lossy().to_string());
}
if self.add_setup_to_ld_library_path {
let new_path = match env.get(LD_LIBRARY_PATH) {
Some(v) => update_path(v.clone().into(), &setup_dir)?,
None => get_path_with_directory(LD_LIBRARY_PATH, &setup_dir)?,
Some(v) => update_path(v.clone().into(), setup_dir)?,
None => get_path_with_directory(LD_LIBRARY_PATH, setup_dir)?,
};
env.insert(
LD_LIBRARY_PATH.to_string(),
@ -348,7 +348,7 @@ impl<'a> Tester<'a> {
Err(error) => (None, Some(error), None),
}
} else {
match run_cmd(&self.exe_path, argv.clone(), &env, self.timeout).await {
match run_cmd(self.exe_path, argv.clone(), &env, self.timeout).await {
Ok(output) => (None, None, Some(output)),
Err(error) => (None, Some(error), None),
}

View File

@ -80,7 +80,7 @@ impl<'a> LibFuzzer<'a> {
let expand = Expand::new()
.target_exe(&self.exe)
.target_options(&self.options)
.target_options(self.options)
.setup_dir(&self.setup_dir)
.set_optional(corpus_dir, |tester, corpus_dir| {
tester.input_corpus(&corpus_dir)
@ -141,7 +141,7 @@ impl<'a> LibFuzzer<'a> {
files.shuffle(&mut rng);
}
for file in files.iter().take(5) {
self.check_input(&file).await.with_context(|| {
self.check_input(file).await.with_context(|| {
format!("checking input corpus: {}", file.display())
})?;
seen_inputs = true;
@ -243,7 +243,7 @@ impl<'a> LibFuzzer<'a> {
let mut options = self.options.to_owned();
options.push("{input}".to_string());
let mut tester = Tester::new(&self.setup_dir, &self.exe, &options, &self.env)
let mut tester = Tester::new(&self.setup_dir, &self.exe, &options, self.env)
.check_asan_stderr(true)
.check_retry_count(retry)
.add_setup_to_path(true)

View File

@ -14,7 +14,6 @@ pub struct DirectoryMonitor {
dir: PathBuf,
notify_events: UnboundedReceiver<DebouncedEvent>,
watcher: notify::RecommendedWatcher,
terminated: bool,
}
impl DirectoryMonitor {
@ -32,7 +31,6 @@ impl DirectoryMonitor {
dir,
notify_events,
watcher,
terminated: false,
}
}
@ -47,7 +45,6 @@ impl DirectoryMonitor {
}
pub fn stop(&mut self) -> Result<()> {
self.terminated = true;
self.watcher.unwatch(self.dir.clone())?;
Ok(())
}

View File

@ -285,7 +285,7 @@ impl From<u64> for Address {
// Find the module-relative address of `addr`, if it exists.
fn find_module_rva(addr: u64, maps: &[MapRange]) -> Option<Rva> {
let mapping = find_mapping(addr, &maps)?;
let mapping = find_mapping(addr, maps)?;
// Offset into the mapped image of some object file, but _not_
// the file itself.

View File

@ -151,13 +151,13 @@ pub(crate) fn parse_summary_base(text: &str) -> Option<(String, String, String)>
}
pub(crate) fn parse_summary(text: &str) -> Result<(String, String, String)> {
if let Some((summary, sanitizer, fault_type)) = parse_summary_base(&text) {
if let Some((summary, sanitizer, fault_type)) = parse_summary_base(text) {
return Ok((summary, sanitizer, fault_type));
}
if let Some((summary, sanitizer, fault_type)) = parse_asan_abort_error(&text) {
if let Some((summary, sanitizer, fault_type)) = parse_asan_abort_error(text) {
return Ok((summary, sanitizer, fault_type));
}
if let Some((summary, sanitizer, fault_type)) = parse_asan_runtime_error(&text) {
if let Some((summary, sanitizer, fault_type)) = parse_asan_runtime_error(text) {
return Ok((summary, sanitizer, fault_type));
}

View File

@ -165,11 +165,11 @@ impl CrashLog {
let stack_filter = get_stack_filter();
let mut minimized_stack_details: Vec<StackEntry> = stack
.iter()
.filter_map(|x| filter_funcs(x, &stack_filter))
.filter_map(|x| filter_funcs(x, stack_filter))
.collect();
// if we don't have a minimized stack, if one of these functions is on
// the stack, use it
for entry in &[
for entry in [
"LLVMFuzzerTestOneInput",
"fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long)",
"main",
@ -177,7 +177,7 @@ impl CrashLog {
if !minimized_stack_details.is_empty() {
break;
}
let value = Some(String::from(*entry));
let value = Some(entry.to_string());
minimized_stack_details = stack
.iter()
.filter_map(|x| {
@ -268,13 +268,13 @@ fn stack_function_lines(stack: &[StackEntry]) -> Vec<String> {
fn parse_summary(text: &str) -> Result<(String, String, String)> {
// eventually, this should be updated to support multiple callstack formats
asan::parse_summary(&text)
asan::parse_summary(text)
}
fn parse_scariness(text: &str) -> (Option<u32>, Option<String>) {
// eventually, this should be updated to support multiple callstack formats,
// including building this value
match asan::parse_scariness(&text) {
match asan::parse_scariness(text) {
Some((x, y)) => (Some(x), Some(y)),
None => (None, None),
}

View File

@ -26,7 +26,7 @@ fn edit_exclusion_list<F: Fn(RegKey) -> ::core::result::Result<(), std::io::Erro
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
// We want to set both the 32 and 64 bit registries.
for flags in &[0, KEY_WOW64_32KEY] {
for flags in [0, KEY_WOW64_32KEY] {
let exclusion_list = hklm
.open_subkey_with_flags(AEDEBUG_EXCLUSION_LIST, KEY_SET_VALUE | flags)
.context("Opening AeDebug\\AutoExclusionList")?;