1# MISRA Compliance for FreeRTOS-Kernel 2FreeRTOS-Kernel is MISRA C:2012 compliant. This directory contains a project to 3run [Synopsys Coverity](https://www.synopsys.com/software-integrity/security-testing/static-analysis-sast.html) 4for checking MISRA compliance. 5 6> **Note** 7Coverity version 2022.6.1 incorrectly infers the type of `pdTRUE` and `pdFALSE` 8as boolean because of their names, resulting in multiple false positive warnings 9about type mismatch. We replace `pdTRUE` with `pdPASS` and `pdFALSE` with 10`pdFAIL` to avoid these false positive warnings. This workaround will not be 11needed after Coverity fixes the issue of incorrectly inferring the type of 12`pdTRUE` and `pdFALSE` as boolean. 13 14Deviations from the MISRA C:2012 guidelines are documented in 15[MISRA.md](../../MISRA.md) and [coverity_misra.config](coverity_misra.config) 16files. 17 18## Getting Started 19### Prerequisites 20Coverity can be run on any platform mentioned [here](https://sig-docs.synopsys.com/polaris/topics/c_coverity-compatible-platforms.html). 21The following are the prerequisites to generate coverity report: 22 231. CMake version > 3.13.0 (You can check whether you have this by typing `cmake --version`). 242. GCC compiler. 25 - See download and installation instructions [here](https://gcc.gnu.org/install/). 263. Clone the repo using the following command: 27 - `git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git ./FreeRTOS-Kernel` 28 29### Generating Report 30Go to the root directory of the FreeRTOS-Kernel repo and run the following 31commands in a terminal: 321. Update the compiler configuration in Coverity: 33 ~~~ 34 cov-configure --force --compiler cc --comptype gcc 35 ~~~ 362. Create the build files using CMake in a `build` directory: 37 ~~~ 38 cmake -B build -S examples/coverity 39 ~~~ 403. Build the (pseudo) application: 41 ~~~ 42 cd build/ 43 cov-build --emit-complementary-info --dir cov-out make 44 ~~~ 454. Go to the Coverity output directory (`cov-out`) and begin Coverity static 46 analysis: 47 ~~~ 48 cd cov-out/ 49 cov-analyze --dir ./cov-out \ 50 --coding-standard-config ../examples/coverity/coverity_misra.config \ 51 --tu-pattern "file('.*/FreeRTOS/Source/[A-Za-z_]*\.c') 52 ~~~ 535. Generate the HTML report: 54 ~~~ 55 cov-format-errors --dir ./cov-out --html-output html-output 56 ~~~ 57 58HTML report should now be generated in a directory named `html-output`. 59