]> begriffs open source - freertos/blob - MISRA.md
Update example cmake project path (#851)
[freertos] / MISRA.md
1 # MISRA Compliance
2
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,
9 are listed below.
10
11 Additionally, [MISRA configuration](#misra-configuration) contains project
12 wide deviations.
13
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 ):
17 ```
18 grep 'MISRA Ref 8.4.1' . -rI
19 ```
20
21 #### Rule 8.4
22
23 _Ref 8.4.1_
24
25 - MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an
26         object or function with external linkage is defined.
27         This rule requires that a compatible declaration is made available
28         in a header file when an object with external linkage is defined.
29         pxCurrentTCB(s) is defined with external linkage but it is only
30         referenced from the assembly code in the port files. Therefore, adding
31         a declaration in header file is not useful as the assembly code will
32         still need to declare it separately.
33
34 ### MISRA configuration
35
36 Copy below content to `misra.conf` to run Coverity on FreeRTOS-Kernel.
37
38 ```
39 // MISRA C-2012 Rules
40 {
41     version : "2.0",
42     standard : "c2012",
43     title: "Coverity MISRA Configuration",
44     deviations : [
45         // Disable the following rules.
46         {
47             deviation: "Directive 4.8",
48             reason: "HeapRegion_t and HeapStats_t are used only in heap files but declared in portable.h which is included in multiple source files. As a result, these definitions appear in multiple source files where they are not used."
49         },
50         {
51             deviation: "Directive 4.9",
52             reason: "FreeRTOS-Kernel is optimised to work on small micro-controllers. To achieve that, function-like macros are used."
53         },
54         {
55             deviation: "Rule 1.2",
56             reason: "The __attribute__ tags are used via macros which are defined in port files."
57         },
58         {
59             deviation: "Rule 3.1",
60             reason: "We post HTTP links in code comments which contain // inside comments blocks."
61         },
62         {
63             deviation: "Rule 8.7",
64             reason: "API functions are not used by the library outside of the files they are defined; however, they must be externally visible in order to be used by an application."
65         },
66         {
67             deviation: "Rule 11.5",
68             reason: "Allow casts from `void *`. List owner, pvOwner, is stored as `void *` and are cast to various types for use in functions."
69         }
70     ]
71 }
72 ```