3 FreeRTOS-Kernel conforms to [MISRA C:2012](https://www.misra.org.uk/misra-c)
4 guidelines, with the deviations listed below. Compliance is checked with
5 Coverity static analysis. Since the FreeRTOS kernel is designed for
6 small-embedded devices, it needs to have a very small memory footprint and
7 has to be efficient. To achieve that and to increase the performance, it
8 deviates from some MISRA rules. The specific deviations, suppressed inline,
11 Additionally, [MISRA configuration file](examples/coverity/coverity_misra.config)
12 contains project wide deviations.
14 ### Suppressed with Coverity Comments
15 To find the violation references in the source files run grep on the source code
16 with ( Assuming rule 8.4 violation; with justification in point 1 ):
18 grep 'MISRA Ref 8.4.1' . -rI
23 MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an
24 object or function with external linkage is defined.
27 - pxCurrentTCB(s) is defined with external linkage but it is only referenced
28 from the assembly code in the port files. Therefore, adding a declaration in
29 header file is not useful as the assembly code will still need to declare it
33 - xQueueRegistry is defined with external linkage because it is accessed by the
34 kernel unit tests. It is not meant to be directly accessed by the application
35 and therefore, not declared in a header file.
39 MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly
40 one external definition.
43 - This rule prohibits an identifier with external linkage to have multiple
44 definitions or no definition. FreeRTOS hook functions are implemented in
45 the application and therefore, have no definition in the Kernel code.
48 MISRA C:2012 Rule 11.1: Conversions shall not be performed between a pointer to
49 function and any other type.
52 - The pointer to function is casted into void to avoid unused parameter
53 compiler warning when Stream Buffer's Tx and Rx Completed callback feature is
58 MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to
59 object type and a pointer to a different object type.
62 - This rule prohibits casting a pointer to object into a pointer to a
63 different object because it may result in an incorrectly aligned pointer,
64 leading to undefined behavior. Even if the casting produces a correctly
65 aligned pointer, the behavior may be still undefined if the pointer is
66 used to access an object. FreeRTOS deliberately creates external aliases
67 for all the kernel object types (StaticEventGroup_t, StaticQueue_t,
68 StaticStreamBuffer_t, StaticTimer_t and StaticTask_t) for data hiding
69 purposes. The internal object types and the corresponding external
70 aliases are guaranteed to have the same size and alignment which is
71 checked using configASSERT.
76 MISRA C:2012 Rule 11.5: A conversion should not be performed from pointer to
77 void into pointer to object.
78 This rule prohibits conversion of a pointer to void into a pointer to
79 object because it may result in an incorrectly aligned pointer leading
80 to undefined behavior.
83 - The memory blocks returned by pvPortMalloc() are guaranteed to meet the
84 architecture alignment requirements specified by portBYTE_ALIGNMENT.
85 The casting of the pointer to void returned by pvPortMalloc() is,
86 therefore, safe because it is guaranteed to be aligned.
89 - The conversion from a pointer to void into a pointer to EventGroup_t is
90 safe because it is a pointer to EventGroup_t, which is returned to the
91 application at the time of event group creation for data hiding
95 - The conversion from a pointer to void in list macros for list item owner
96 is safe because the type of the pointer stored and retrieved is the
100 - The conversion from a pointer to void into a pointer to EventGroup_t is
101 safe because it is a pointer to EventGroup_t, which is passed as a
102 parameter to the xTimerPendFunctionCallFromISR API when the callback is
106 - The conversion from a pointer to void into a pointer to uint8_t is safe
107 because data storage buffers are implemented as uint8_t arrays for the
108 ease of sizing, alignment and access.
112 MISRA C-2012 Rule 21.6: The Standard Library input/output functions shall not
116 - The Standard Library function snprintf is used in vTaskListTasks and
117 vTaskGetRunTimeStatistics APIs, both of which are utility functions only and
118 are not considered part of core kernel implementation.