FreeRTOS-Kernel conforms to MISRA C:2012 guidelines, with the deviations listed below. Compliance is checked with Coverity static analysis version 2023.6.1. Since the FreeRTOS kernel is designed for small-embedded devices, it needs to have a very small memory footprint and has to be efficient. To achieve that and to increase the performance, it deviates from some MISRA rules. The specific deviations, suppressed inline, are listed below.
Additionally, MISRA configuration file contains project wide deviations.
To find the violation references in the source files run grep on the source code with ( Assuming rule 8.4 violation; with justification in point 1 ):
grep 'MISRA Ref 8.4.1' . -rI
MISRA C:2012 Dir 4.7: If a function returns error information, then that error information shall be tested.
Ref 4.7.1
taskENTER_CRITICAL_FROM_ISR returns the interrupt mask and not any error information. Therefore, there is no need test the return value.MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an object or function with external linkage is defined.
Ref 8.4.1
Ref 8.4.2
MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly one external definition.
Ref 8.6.1
MISRA C:2012 Rule 11.1: Conversions shall not be performed between a pointer to function and any other type.
Ref 11.1.1
MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to object type and a pointer to a different object type.
Ref 11.3.1
MISRA C:2012 Rule 11.5: A conversion should not be performed from pointer to void into pointer to object. This rule prohibits conversion of a pointer to void into a pointer to object because it may result in an incorrectly aligned pointer leading to undefined behavior.
Ref 11.5.1
Ref 11.5.2
Ref 11.5.3
Ref 11.5.4
Ref 11.5.5
MISRA C-2012 Rule 14.3: Controlling expressions shall not be invariant.
Ref 14.3
configMAX_TASK_NAME_LEN , taskRESERVED_TASK_NAME_LENGTH and SIZE_MAX are evaluated to constants at compile time and may vary based on the build configuration.MISRA C-2012 Rule 18.1: A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand.
Ref 18.1
MISRA C-2012 Rule 21.6: The Standard Library input/output functions shall not be used.
Ref 21.6.1
Certain deviating code is left unsuppressed for awareness. These violations will be reported when audited by a MISRA-checking static analysis tool.
Some of these unsuppressed exceptions correspond to example code provided either for demonstration or verification of the FreeRTOS kernel. This code is not considered part of the kernel implementation and should not be used in an application.
Other unsuppressed violations are left present in the kernel implementation as implementations, code, or other missing functionality being flagged for violations will be present with the porting layer provided by the application. The presence of these errors after providing a port indicates a valid MISRA issue.
MISRA C:2012 Dir 2.1: A project shall not contain unreachable code
Ref 2.1
Simplified example contains unreachable code for demonstration of FreeRTOS scheduler. A production implementation should not contain this.
Affected Files:
MISRA C:2012 Dir 2.2: There shall be no dead code.
Ref 2.2
vPortEndScheduler is erroneously determined to be dead code due to the use of a simplified verification port.
Affected Files:
MISRA C:2012 Dir 4.12: Dynamic allocation shall not be used
Ref 4.12
Heap memory solutions utilize pvPortMalloc/vPortFree to provide heap memory for dynamic object allocation. These functions may rely upon the malloc/free of the underlying port. Static allocation is recommended for MISRA compliant applications.
Affected Files:
MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly one external definition.
Ref 8.6.1
MISRA C-2012 Rule 21.3: The memory allocation and deallocation functions of <stdlib.h> shall not be used.
Ref 21.3
See justification from Directive 4.12
Affected Files:
MISRA C-2012 Rule 21.6: The Standard Library input/output functions shall not be used.
Ref 21.6.1
The Standard Library function printf is used in examples to provide a simple getting started demonstration. This example is not considered part of the kernel implementation.
Affected Files: