2 Project MISRA C:2012 Deviations
A list of all Project Deviations, defined as deviations from MISRA C guidelines in a particular class of circumstances, for all files in the LIN Responder library
2.1 Project MISRA C:2012 Deviations
Required: misra-c2012-19.2
Justification: This deviation applies to each LIN data frame union defined in the LIN
configuration file. LIN data frames consist of one to eight data bytes, packed with
varying sizes of signal data bits and bytes. These signal data are arranged to fit in a
frame and will be read and written individually in the application. Unions provide the
most practical solution for accessing the full data frame and individual signal data.
The rationale for this rule states: “If a union member
is written and then a different union member is read back, the behavior depends on the
relative sizes of the members. If this rule is not followed, the kinds of behavior that
need to be determined are: Padding, Alignment, Endianness, and Bit-order”. The LIN
library ensures that each signal byte and bit field within a frame are defined and
arranged properly with careful consideration of the behaviors listed in the standard.
Thus, this deviation is suppressed for all LIN data frame unions. There are no
consequences associated with this deviation. E.g.:
/* cppcheck-suppress misra-c2012-19.2 */ typedef union { struct { unsigned Frame1_BoolSignal : 1; unsigned : 3; unsigned Frame1_Scalar4Signal : 4; unsigned Frame1_Scalar16SignalL : 8; unsigned Frame1_Scalar16SignalH : 8; l_u8 Frame1_ArraySignal[3]; }; l_u8 data[FRAME1_BYTES]; } frame1_t;