Skip to content

Commit

Permalink
Fix some warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Jan 8, 2024
1 parent a62097c commit 818ca0a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 48 deletions.
16 changes: 2 additions & 14 deletions teleprobe/src/auth/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,7 @@ use jsonwebtoken::{Algorithm, DecodingKey, Validation};
use serde::de::DeserializeOwned;
use serde::Deserialize;

mod base64 {
use serde::{Deserialize, Deserializer, Serialize, Serializer};

pub fn serialize<S: Serializer>(v: &[u8], s: S) -> Result<S::Ok, S::Error> {
let base64 = base64::encode(v);
String::serialize(&base64, s)
}

pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
let base64 = String::deserialize(d)?;
base64::decode(base64.as_bytes()).map_err(serde::de::Error::custom)
}
}

#[allow(dead_code)]
#[derive(Clone, Deserialize)]
struct OpenIDConfiguration {
issuer: String,
Expand All @@ -33,6 +20,7 @@ struct JsonWebKeySet {
}

#[derive(Clone, Deserialize)]
#[allow(dead_code)]
struct JsonWebKey {
kty: String,
kid: String,
Expand Down
23 changes: 0 additions & 23 deletions teleprobe/src/logutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,6 @@ mod log_panics {
}
}

/// Determines how backtraces will be displayed.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BacktraceMode {
/// Backtraces will be omitted from the log.
Off,
/// Backtraces will include addresses, but no symbol names or locations.
Unresolved,
/// Backtraces will include addresses as well as symbol names and locations when possible.
Resolved,
}

/// Configures the panic hook, ending with initialization.
///
/// ## Example
Expand All @@ -199,18 +188,6 @@ mod log_panics {
}
}

/// Controls how backtraces are displayed.
///
/// The default when backtraces are enabled is [`BacktraceMode::Resolved`].
pub fn backtrace_mode(mut self, mode: BacktraceMode) -> Self {
self.make_backtrace = match mode {
BacktraceMode::Off => || Backtrace::from(vec![]),
BacktraceMode::Unresolved => Backtrace::new_unresolved,
BacktraceMode::Resolved => Backtrace::default,
};
self
}

/// Initializes the panic hook.
///
/// After this method is called, all panics will be logged rather than printed
Expand Down
6 changes: 5 additions & 1 deletion teleprobe/src/probe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ pub struct Opts {
}

pub fn list() -> Result<()> {
let start = Instant::now();
let lister = Lister::new();
let probes = lister.list_all();
let t = Instant::now() - start;
println!("took {} ms", t.as_millis());

if probes.is_empty() {
println!("No probe found!");
return Ok(());
Expand All @@ -62,7 +66,7 @@ pub fn connect(opts: &Opts) -> Result<Session> {
let Some(selector) = &opts.probe else {
bail!("power reset requires a serial number");
};
let Some(serial_number) = &selector.serial_number else {
if selector.serial_number.is_none() {
bail!("power reset requires a serial number");
};

Expand Down
10 changes: 0 additions & 10 deletions teleprobe/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ impl Runner {
// NOTE we don't load `.bss` because the app (cortex-m-rt) will zero it
let candidates = [".vector_table", ".text", ".rodata", ".data"];

let mut sections = vec![];
let mut vector_table = None;
for sect in elf.sections() {
if let Ok(name) = sect.name() {
Expand Down Expand Up @@ -111,8 +110,6 @@ impl Runner {
hard_fault: data[3],
});
}

sections.push(Section { start, data });
}
}
}
Expand Down Expand Up @@ -577,13 +574,6 @@ fn get_rtt_main_from(elf: &ElfFile) -> anyhow::Result<(Option<u32>, u32)> {
Ok((rtt, main.ok_or_else(|| anyhow!("`main` symbol not found"))?))
}

/// ELF section to be loaded onto the target
#[derive(Debug)]
struct Section {
start: u32,
data: Vec<u32>,
}

/// The contents of the vector table
#[derive(Debug)]
struct VectorTable {
Expand Down

0 comments on commit 818ca0a

Please sign in to comment.