Skip to content

Commit 11227c1

Browse files
mkjjk-ozlabs
authored andcommitted
pldm-file: Use static CRC32. Update crc crate
Signed-off-by: Matt Johnston <[email protected]>
1 parent 1df5490 commit 11227c1

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = "https://github.com/CodeConstruct/mctp-rs"
1111
anyhow = "1.0.80"
1212
argh = "0.1.12"
1313
chrono = { version = "0.4", default-features = false }
14-
crc = "3.0"
14+
crc = "3.3"
1515
defmt = "0.3"
1616
deku = { git = "https://github.com/CodeConstruct/deku.git", tag = "cc/deku-v0.19.1/no-alloc-3", default-features = false }
1717
embedded-io-adapters = { version = "0.6", features = ["std", "futures-03"] }

pldm-file/src/host.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ impl std::fmt::Display for PldmFileError {
8080
}
8181
}
8282

83+
const CRC32: crc::Crc<u32, crc::Table<16>> =
84+
crc::Crc::<u32, crc::Table<16>>::new(&crc::CRC_32_ISO_HDLC);
85+
8386
type Result<T> = std::result::Result<T, PldmFileError>;
8487

8588
impl<const N: usize> Responder<N> {
@@ -402,8 +405,8 @@ impl<const N: usize> Responder<N> {
402405
let data = &mut resp_data[l..];
403406
host.read(data, xfer_ctx.start + offset)
404407
.map_err(|_| CCode::ERROR)?;
405-
let crc32 = crc::Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
406-
let cs = crc32.checksum(data);
408+
409+
let cs = CRC32.checksum(data);
407410
resp_data.extend_from_slice(&cs.to_le_bytes());
408411

409412
xfer_ctx.offset = offset;

0 commit comments

Comments
 (0)