Skip to content

Commit 46ea365

Browse files
committed
firmware_type: rustfmt of the FirmwareType code
1 parent 201f8b8 commit 46ea365

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/firmware_type.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
use std::array::TryFromSliceError;
77
use std::fmt::Display;
88

9-
use clap::{ValueEnum, builder::PossibleValue};
9+
use clap::ValueEnum;
10+
use clap::builder::PossibleValue;
1011
use color_eyre::eyre::{Context, Result, eyre};
1112
use log::debug;
1213

13-
use crate::{bmp::BmpPlatform, firmware_file::FirmwareFile};
14+
use crate::bmp::BmpPlatform;
15+
use crate::firmware_file::FirmwareFile;
1416

1517
/// Represents a conceptual Vector Table for Armv7 processors.
1618
pub struct Armv7mVectorTable<'b>
@@ -73,21 +75,19 @@ impl FirmwareType
7375
/// This function panics if `firmware.len() < 8`.
7476
pub fn detect_from_firmware(platform: BmpPlatform, firmware_file: &FirmwareFile) -> Result<Self>
7577
{
76-
// If the firmware image has a load address
77-
if let Some(load_address) = firmware_file.load_address() {
78-
// Check if the address is the bootloader area for the platform
79-
let boot_start = platform.load_address(Self::Bootloader);
80-
return Ok(
81-
if load_address == boot_start {
82-
Self::Bootloader
83-
} else {
84-
Self::Application
85-
}
86-
);
87-
}
88-
89-
// If the firmware doesn't have a known load address, fall back to figuring it out
90-
// from the NVIC table at the front of the image
78+
// If the firmware image has a load address
79+
if let Some(load_address) = firmware_file.load_address() {
80+
// Check if the address is the bootloader area for the platform
81+
let boot_start = platform.load_address(Self::Bootloader);
82+
return Ok(if load_address == boot_start {
83+
Self::Bootloader
84+
} else {
85+
Self::Application
86+
});
87+
}
88+
89+
// If the firmware doesn't have a known load address, fall back to figuring it out
90+
// from the NVIC table at the front of the image
9191
let buffer = &firmware_file.data()[0..(4 * 2)];
9292

9393
let vector_table = Armv7mVectorTable::from_bytes(buffer);

0 commit comments

Comments
 (0)