Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Dec 6, 2024
1 parent d0b8f5f commit 9f85f45
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions rust/src/nasl/builtin/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn find_path_of_command(cmd: &str) -> Result<PathBuf, SysError> {
if output.status.success() {
let stdout = String::from_utf8(output.stdout).map_err(|_| make_err())?;
let path = Path::new(&stdout);
let dir = path.parent().ok_or_else(|| make_err())?.to_owned();
let dir = path.parent().ok_or_else(make_err)?.to_owned();
Ok(dir)
} else {
Err(SysError::CommandNotFound(cmd.to_string()))
Expand All @@ -61,10 +61,7 @@ async fn pread(
for arg in argv.iter() {
real_cmd.arg(arg);
}
let out = real_cmd
.output()
.await
.map_err(|e| SysError::SpawnProcess(e))?;
let out = real_cmd.output().await.map_err(SysError::SpawnProcess)?;
let stdout = String::from_utf8(out.stdout).unwrap();
Ok(stdout)
}
Expand All @@ -90,7 +87,7 @@ async fn fread(path: &Path) -> Result<String, FnError> {
async fn fwrite(data: &str, file: &Path) -> Result<usize, FnError> {
tokio::fs::write(file, data)
.await
.map_err(|e| SysError::WriteFile(e))?;
.map_err(SysError::WriteFile)?;
let num_bytes = data.len();
Ok(num_bytes)
}
Expand All @@ -99,7 +96,7 @@ async fn fwrite(data: &str, file: &Path) -> Result<usize, FnError> {
async fn file_stat(path: &Path) -> Result<u64, FnError> {
let metadata = tokio::fs::metadata(path)
.await
.map_err(|e| SysError::ReadFileMetadata(e))?;
.map_err(SysError::ReadFileMetadata)?;
Ok(metadata.len())
}

Expand Down

0 comments on commit 9f85f45

Please sign in to comment.