Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
anfedotoff committed Oct 6, 2023
1 parent f0180ab commit a4c3603
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
9 changes: 6 additions & 3 deletions casr/src/bin/casr-cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ use cursive::View;
use regex::Regex;
use serde_json::Value;
use std::collections::{BTreeMap, HashSet};
use std::fmt::Write;
use std::fs;
use std::fs::{File, OpenOptions};
use std::io::prelude::*;
use std::io::{BufReader, Write};
use std::io::{BufReader, Write as BufWrite};
use std::path::{Path, PathBuf};

use anyhow::{bail, Context, Result};
Expand Down Expand Up @@ -588,8 +589,10 @@ fn build_slider_report(
let mut state = report
.registers
.iter()
.map(|(k, v)| format!("{k}: 0x{v:x}\n"))
.collect::<String>();
.fold(String::new(), |mut output, (k, v)| {
let _ = writeln!(output, "{k}: 0x{v:x}");
output
});

if !report.disassembly.is_empty() {
state.push_str(&format!("\n{}", &report.disassembly.join("\n")));
Expand Down
2 changes: 1 addition & 1 deletion casr/src/triage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a> CrashInfo {

// Add envs
if self.target_args.iter().any(|x| x.eq("-detect_leaks=0")) {
let asan_options = std::env::var("ASAN_OPTIONS").unwrap_or(String::new());
let asan_options = std::env::var("ASAN_OPTIONS").unwrap_or_default();
casr_cmd.env(
"ASAN_OPTIONS",
if asan_options.is_empty() {
Expand Down
6 changes: 4 additions & 2 deletions libcasr/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,10 @@ pub fn cluster_reports(casreps: &[CrashReport]) -> Result<Vec<u32>> {
#[cfg(test)]
mod tests {
use super::*;
use crate::constants::*;
use crate::init_ignored_frames;
use crate::{
init_ignored_frames,
stacktrace::{Filter, Stacktrace},
};

#[test]
fn test_report_display() {
Expand Down
16 changes: 9 additions & 7 deletions libcasr/src/stacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::error::*;
use kodama::{linkage, Method};
use regex::Regex;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::fmt::{self, Write};
use std::sync::RwLock;

// Re-export types from gdb_command for convenient use from Casr library
Expand Down Expand Up @@ -306,8 +306,10 @@ impl Filter for Stacktrace {
let rfunction = if !function_regexes.is_empty() {
let rstring = function_regexes
.iter()
.map(|s| format!("({s})|"))
.collect::<String>();
.fold(String::new(), |mut output, s| {
let _ = write!(output, "({s})|");
output
});
Regex::new(&rstring[0..rstring.len() - 1]).unwrap()
} else {
Regex::new(r"^[^.]$").unwrap()
Expand All @@ -316,10 +318,10 @@ impl Filter for Stacktrace {
// Compile file regexp.
let file_regexes = STACK_FRAME_FILEPATH_IGNORE_REGEXES.read().unwrap();
let rfile = if !file_regexes.is_empty() {
let rstring = file_regexes
.iter()
.map(|s| format!("({s})|"))
.collect::<String>();
let rstring = file_regexes.iter().fold(String::new(), |mut output, s| {
let _ = write!(output, "({s})|");
output
});
Regex::new(&rstring[0..rstring.len() - 1]).unwrap()
} else {
Regex::new(r"^[^.]$").unwrap()
Expand Down

0 comments on commit a4c3603

Please sign in to comment.