Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
updates related to cargo clippy 1.51.0 (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmc-msft authored Apr 1, 2021
1 parent 03fc386 commit f6adad3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/agent/onefuzz-agent/src/local/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ pub fn get_synced_dirs(
args: &ArgMatches<'_>,
) -> Result<Vec<SyncedDir>> {
let current_dir = std::env::current_dir()?;
let dirs: Result<Vec<SyncedDir>> = args
.values_of_os(name)
args.values_of_os(name)
.ok_or_else(|| anyhow!("argument '{}' not specified", name))?
.enumerate()
.map(|(index, remote_path)| {
Expand All @@ -165,8 +164,7 @@ pub fn get_synced_dirs(
path,
})
})
.collect();
Ok(dirs?)
.collect()
}

fn register_cleanup(job_id: Uuid) -> Result<()> {
Expand Down
6 changes: 3 additions & 3 deletions src/agent/onefuzz-agent/src/tasks/merge/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ pub async fn spawn(config: Arc<Config>) -> Result<()> {
}
}

async fn process_message(config: Arc<Config>, input_url: &Url, tmp_dir: &PathBuf) -> Result<()> {
async fn process_message(config: Arc<Config>, input_url: &Url, tmp_dir: &Path) -> Result<()> {
let input_path = utils::download_input(input_url.clone(), &config.unique_inputs.path).await?;
info!("downloaded input to {}", input_path.display());

info!("Merging corpus");
match merge(&config, tmp_dir).await {
Ok(_) => {
// remove the 'queue' folder
let mut queue_dir = tmp_dir.clone();
let mut queue_dir = tmp_dir.to_path_buf();
queue_dir.push("queue");
let _delete_output = tokio::fs::remove_dir_all(queue_dir).await;
let synced_dir = SyncedDir {
path: tmp_dir.clone(),
path: tmp_dir.to_path_buf(),
url: config.unique_inputs.url.clone(),
};
synced_dir.sync_push().await?
Expand Down
6 changes: 4 additions & 2 deletions src/agent/onefuzz-agent/src/tasks/stats/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ use onefuzz_telemetry::Event::runtime_stats;
use serde::Deserialize;
pub const STATS_DELAY: std::time::Duration = std::time::Duration::from_secs(30);

// TODO - remove unkonwn_lints once GitHub build agents are at 1.51.0 or later
#[derive(Debug, Deserialize, Clone)]
pub enum StatsFormat {
AFL,
#[serde(alias = "AFL")]
Afl,
}

pub async fn monitor_stats(path: Option<String>, format: Option<StatsFormat>) -> Result<(), Error> {
if let Some(path) = path {
if let Some(format) = format {
loop {
let stats = match format {
StatsFormat::AFL => afl::read_stats(&path).await,
StatsFormat::Afl => afl::read_stats(&path).await,
};
if let Ok(stats) = stats {
log_events!(runtime_stats; stats);
Expand Down
2 changes: 2 additions & 0 deletions src/agent/onefuzz/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::path::PathBuf;
pub const PATH: &str = "PATH";
pub const LD_LIBRARY_PATH: &str = "LD_LIBRARY_PATH";

#[allow(clippy::ptr_arg)]
pub fn update_path(path: OsString, to_add: &PathBuf) -> Result<OsString> {
let mut paths: Vec<_> = std::env::split_paths(&path).collect();
if !paths.contains(to_add) {
Expand All @@ -16,6 +17,7 @@ pub fn update_path(path: OsString, to_add: &PathBuf) -> Result<OsString> {
Ok(std::env::join_paths(paths)?)
}

#[allow(clippy::ptr_arg)]
pub fn get_path_with_directory(variable: &str, to_add: &PathBuf) -> Result<OsString> {
match std::env::var_os(variable) {
Some(path) => update_path(path, to_add),
Expand Down

0 comments on commit f6adad3

Please sign in to comment.