1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-04 21:48:17 +00:00
This commit is contained in:
Martin Milata 2024-12-02 22:40:26 +01:00 committed by GitHub
commit 9ce612e2a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -93,7 +93,7 @@ if not PROTOC:
PROTOC_PREFIX = Path(PROTOC).resolve().parent.parent
ENUM_ENTRY = c.PrefixedArray(c.Byte, c.Int16ul)
ENUM_ENTRY = c.PrefixedArray(c.Int16ul, c.Int16ul)
FIELD_STRUCT = c.Struct(
"tag" / c.Byte,

View File

@ -209,7 +209,7 @@ pub unsafe fn get_msg(msg_offset: u16) -> MsgDef {
unsafe fn get_enum(enum_offset: u16) -> EnumDef {
// #[repr(C, packed)]
// struct EnumDef {
// count: u8,
// count: u16,
// vals: [u16],
// }
@ -217,8 +217,10 @@ unsafe fn get_enum(enum_offset: u16) -> EnumDef {
// definition inside `ENUM_DEFS`.
unsafe {
let ptr = ENUM_DEFS.as_ptr().add(enum_offset as usize);
let count = ptr.offset(0).read() as usize;
let vals = ptr.offset(1);
let count_lo = ptr.offset(0).read();
let count_hi = ptr.offset(1).read();
let count = u16::from_le_bytes([count_lo, count_hi]) as usize;
let vals = ptr.offset(2);
EnumDef {
values: slice::from_raw_parts(vals.cast(), count),