commaai / panda

code powering the comma.ai panda
MIT License
1.54k stars 783 forks source link

misra21.15 #2030

Closed maxime-desroches closed 2 months ago

maxime-desroches commented 2 months ago

Casting to uint8_t is a good solution given the nature of the structs we are copying to/from:

can_health_t is packed so it is fine to consider it an array of uint8_t

ControlPacket_t is packed so it is fine to consider it an array of uint8_t + trying to set each fields manually will make assumptions about endianness (since some ControlPacket_t elements are uint16_t and the buffer elements are uint8_t)

CANPacket_t is mostly a bit field struct that would require getting each fields manually with bit-wise operations and make assumptions about the order of the bits in the struct. But since it is also a packed struct, it is fine to just assume an array of uint8_t and proceed as before.