Skip to content

Commit 5a2b746

Browse files
authored
Merge pull request #44 from Jim-Hodapp-Coaching/address_security_issues
Address all known static analysis security issues and Clippy warnings
2 parents 53cb069 + fabaadf commit 5a2b746

File tree

10 files changed

+36
-38
lines changed

10 files changed

+36
-38
lines changed

cross/get_fw_version/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ doctest = false
1717
test = false
1818

1919
[dependencies]
20-
defmt = "0.3.0"
21-
defmt-rtt = "0.3.0"
20+
defmt = "0.3"
21+
defmt-rtt = "0.3"
2222
cortex-m = "0.7"
2323
cortex-m-rt = "0.7"
2424
embedded-hal = { version = "0.2", features=["unproven"] }
25-
embedded-time = "0.12"
2625
esp32-wroom-rp = { path = "../../esp32-wroom-rp" }
2726
panic-probe = { version = "0.3.0", features = ["print-rtt"] }
2827

29-
rp2040-hal = { version = "0.5", features=["rt", "eh1_0_alpha"] }
28+
rp2040-hal = { version = "0.6", features=["rt", "eh1_0_alpha"] }
3029
rp2040-boot2 = { version = "0.2" }
30+
fugit = "0.3"
3131

3232
[features]
3333
default = ['defmt-default']

cross/get_fw_version/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use panic_probe as _;
2222
use rp2040_hal as hal;
2323

2424
use embedded_hal::spi::MODE_0;
25-
use embedded_time::fixed_point::FixedPoint;
26-
use embedded_time::rate::Extensions;
25+
use fugit::RateExtU32;
2726
use hal::clocks::Clock;
2827
use hal::pac;
2928

@@ -63,7 +62,7 @@ fn main() -> ! {
6362
.ok()
6463
.unwrap();
6564

66-
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
65+
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
6766

6867
// The single-cycle I/O block controls our GPIO pins
6968
let sio = hal::Sio::new(pac.SIO);
@@ -89,7 +88,7 @@ fn main() -> ! {
8988
let mut spi = spi.init(
9089
&mut pac.RESETS,
9190
clocks.peripheral_clock.freq(),
92-
8_000_000u32.Hz(),
91+
8.MHz(),
9392
&MODE_0,
9493
);
9594

cross/join/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ doctest = false
1717
test = false
1818

1919
[dependencies]
20-
defmt = "0.3.0"
21-
defmt-rtt = "0.3.0"
20+
defmt = "0.3"
21+
defmt-rtt = "0.3"
2222
cortex-m = "0.7"
2323
cortex-m-rt = "0.7"
2424
embedded-hal = { version = "0.2", features=["unproven"] }
25-
embedded-time = "0.12"
2625
esp32-wroom-rp = { path = "../../esp32-wroom-rp" }
2726
panic-probe = { version = "0.3.0", features = ["print-rtt"] }
2827

29-
rp2040-hal = { version = "0.5", features=["rt", "eh1_0_alpha"] }
28+
rp2040-hal = { version = "0.6", features=["rt", "eh1_0_alpha"] }
3029
rp2040-boot2 = { version = "0.2" }
30+
fugit = "0.3"
3131

3232
[features]
3333
default = ['defmt-default']

cross/join/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ use panic_probe as _;
2525
use rp2040_hal as hal;
2626

2727
use embedded_hal::spi::MODE_0;
28-
use embedded_time::fixed_point::FixedPoint;
29-
use embedded_time::rate::Extensions;
28+
use fugit::RateExtU32;
3029
use hal::clocks::Clock;
3130
use hal::pac;
3231

@@ -66,7 +65,7 @@ fn main() -> ! {
6665
.ok()
6766
.unwrap();
6867

69-
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
68+
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
7069

7170
// The single-cycle I/O block controls our GPIO pins
7271
let sio = hal::Sio::new(pac.SIO);
@@ -92,7 +91,7 @@ fn main() -> ! {
9291
let mut spi = spi.init(
9392
&mut pac.RESETS,
9493
clocks.peripheral_clock.freq(),
95-
8_000_000u32.Hz(),
94+
8.MHz(),
9695
&MODE_0,
9796
);
9897

esp32-wroom-rp/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
authors = [
33
"Jim Hodapp",
44
"Caleb Bourg",
5-
"Glyn Matthews"
5+
"Glyn Matthews",
6+
"Dilyn Corner"
67
]
78
edition = "2021"
89
readme = "README.md"
910
name = "esp32-wroom-rp"
10-
version = "0.1.0"
11+
version = "0.3.0"
1112
description = "Rust-based Espressif ESP32-WROOM WiFi driver crate for RP2040 series microcontroller boards."
1213

1314
[lib]
@@ -21,7 +22,6 @@ cortex-m = "0.7"
2122
cortex-m-rt = "0.7"
2223
cortex-m-semihosting = "0.5"
2324
embedded-hal = { version = "0.2", features=["unproven"] }
24-
embedded-time = "0.12"
2525

2626
defmt = "0.3"
2727
defmt-rtt = "0.3"

esp32-wroom-rp/src/gpio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ where
130130
}
131131

132132
fn wait_for_esp_ready(&self) {
133-
while self.get_esp_ready() != true {
133+
while !self.get_esp_ready() {
134134
//cortex_m::asm::nop(); // Make sure rustc doesn't optimize this loop out
135135
}
136136
}
137137

138138
fn wait_for_esp_ack(&self) {
139-
while self.get_esp_ack() == false {
139+
while !self.get_esp_ack() {
140140
//cortex_m::asm::nop(); // Make sure rustc doesn't optimize this loop out
141141
}
142142
}

esp32-wroom-rp/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! ```toml
1414
//! [dependencies]
15-
//! esp32_wroom_rp = 0.1
15+
//! esp32_wroom_rp = 0.3
1616
//! ```
1717
//!
1818
//! Next:
@@ -60,7 +60,7 @@
6060
//! let spi = spi.init(
6161
//! &mut pac.RESETS,
6262
//! clocks.peripheral_clock.freq(),
63-
//! 8_000_000u32.Hz(),
63+
//! 8.MHz(),
6464
//! &MODE_0,
6565
//! );
6666
//!
@@ -99,7 +99,7 @@ use embedded_hal::blocking::delay::DelayMs;
9999
const ARRAY_LENGTH_PLACEHOLDER: usize = 8;
100100

101101
/// Highest level error types for this crate.
102-
#[derive(Debug, PartialEq)]
102+
#[derive(Debug, Eq, PartialEq)]
103103
pub enum Error {
104104
/// SPI/I2C related communications error with the ESP32 WiFi target
105105
Bus,
@@ -127,7 +127,7 @@ impl From<protocol::ProtocolError> for Error {
127127
}
128128

129129
/// A structured representation of a connected NINA firmware device's version number (e.g. 1.7.4).
130-
#[derive(Debug, Default, PartialEq)]
130+
#[derive(Debug, Default, Eq, PartialEq)]
131131
pub struct FirmwareVersion {
132132
major: u8,
133133
minor: u8,
@@ -141,16 +141,16 @@ impl FirmwareVersion {
141141

142142
// Takes in 8 bytes (e.g. 1.7.4) and returns a FirmwareVersion instance
143143
fn parse(version: [u8; ARRAY_LENGTH_PLACEHOLDER]) -> FirmwareVersion {
144-
let major: u8;
145-
let minor: u8;
146-
let patch: u8;
144+
let major_version: u8;
145+
let minor_version: u8;
146+
let patch_version: u8;
147147

148-
[major, _, minor, _, patch, _, _, _] = version;
148+
[major_version, _, minor_version, _, patch_version, _, _, _] = version;
149149

150150
FirmwareVersion {
151-
major: major,
152-
minor: minor,
153-
patch: patch,
151+
major: major_version,
152+
minor: minor_version,
153+
patch: patch_version,
154154
}
155155
}
156156
}

esp32-wroom-rp/src/protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub(crate) struct NinaProtocolHandler<'a, B, C> {
241241

242242
// TODO: look at Nina Firmware code to understand conditions
243243
// that lead to NinaProtocolVersionMismatch
244-
#[derive(Debug, PartialEq)]
244+
#[derive(Debug, Eq, PartialEq)]
245245
pub enum ProtocolError {
246246
NinaProtocolVersionMismatch,
247247
CommunicationTimeout,

esp32-wroom-rp/src/protocol/operation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ impl<P> Operation<P> {
1717
// Initializes new Operation instance.
1818
//
1919
// `has_params` defaults to `true`
20-
pub fn new(command: NinaCommand, number_of_params_to_receive: u8) -> Self {
20+
pub fn new(nina_command: NinaCommand, number_of_nina_params_to_receive: u8) -> Self {
2121
Self {
2222
params: Vec::new(),
23-
command: command,
23+
command: nina_command,
2424
has_params: true,
25-
number_of_params_to_receive: number_of_params_to_receive,
25+
number_of_params_to_receive: number_of_nina_params_to_receive,
2626
}
2727
}
2828

esp32-wroom-rp/src/spi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ where
4444
/// Calling this function puts the connected ESP32-WROOM device in a known good state to accept commands.
4545
pub fn init<D: DelayMs<u16>>(
4646
spi: &'a mut S,
47-
control_pins: &'a mut C,
47+
esp32_control_pins: &'a mut C,
4848
delay: &mut D,
4949
) -> Result<Wifi<'a, S, C>, Error> {
5050
let mut wifi = Wifi {
5151
common: WifiCommon {
5252
protocol_handler: NinaProtocolHandler {
5353
bus: spi,
54-
control_pins: control_pins,
54+
control_pins: esp32_control_pins,
5555
},
5656
},
5757
};

0 commit comments

Comments
 (0)