Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 6c1556ee authored by Martin Geisler's avatar Martin Geisler
Browse files

pdl: apply zero-padding correctly on the MSB side of the payload

Before we would always do the zero-padding after the payload. This is
wrong for a big-endian encoding where we need to apply the padding to
the left of the payload instead.

As an example, consider a 24 bit field which is decoded into a 32 bit
Rust value. In little-endian encoding, 3 bytes with values

    0xC0 0xB0 0xA0

should be decoded to the integer 0xA0B0C0. Applying the padding after
the bytes is correct here:

    0xC0 0xB0 0xA0 0x00

is the little-endian encoding of 0xA0B0C0. For big-endian, the correct
encoding is instead

    0x00 0xA0 0xB0 0xC0

Bug: 239038416
Test: atest pdl_inline_tests
Change-Id: I7b28dd99394fdfe4a78a47c453bd7a1e7a74cecb
parent 0e385aee
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment