Address code review comments

This commit is contained in:
Patryk Bęza 2025-01-17 12:41:07 +01:00
parent 2d04ba0508
commit afa524c18c
No known key found for this signature in database
GPG key ID: 9AD1B44D9F6258EC
3 changed files with 16 additions and 33 deletions

View file

@ -35,6 +35,11 @@ pub enum ReportData {
}
fn report_data_to_bytes(data: &[u8], version: u8) -> [u8; REPORT_DATA_LENGTH] {
debug_assert!(
data.len() < REPORT_DATA_LENGTH, // Ensure there is space for the version byte
"Data length exceeds maximum of {} bytes",
REPORT_DATA_LENGTH
);
let mut bytes = [0u8; REPORT_DATA_LENGTH];
bytes[..data.len()].copy_from_slice(data);
bytes[REPORT_DATA_LENGTH - 1] = version;