Static code analysis for FreeRTOS-Plus-TCP library
This directory is made for the purpose of statically testing the MISRA C:2012 compliance of FreeRTOS+TCP using Synopsys Coverity static analysis tool. To that end, this directory provides a CMake file and configuration files required to build an application for the tool to analyze.
Note
For generating the report as outlined below, we have used Coverity version 2018.09.
For details regarding the suppressed violations in the report (which can be generated using the instructions described below), please see the MISRA.md file.
Getting Started
Prerequisites
You can run this on a platform supported by Coverity. The list and other details can be found here. To compile and run the Coverity target successfully, you must have the following:
- CMake version > 3.13.0 (You can check whether you have this by typing
cmake --version) - GCC compiler
- You can see the downloading and installation instructions here.
- Download the repo and include the submodules using the following commands.
git clone --recurse-submodules https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git ./FreeRTOS_TCPcd ./FreeRTOS_TCPgit submodule update --checkout --init --recursive
To build and run coverity:
Go to the root directory of the FreeRTOS-Plus-TCP repo and run the following commands in terminal:
- Update the compiler configuration in Coverity
cov-configure --force --compiler cc --comptype gcc
- Create the build files using CMake in a
builddirectory
cmake -B build -S test/Coverity
- Go to the build directory and copy the coverity configuration file
cd build/
cp ../test/Coverity/coverity_misra.config .
- Build the (pseudo) application
cov-build --emit-complementary-info --dir cov-out make
- Go to the Coverity output directory (
cov-out) and begin Coverity static analysis
cd cov-out/
cov-analyze --dir . --coding-standard-config ../coverity_misra.config --tu-pattern "file('.*/FreeRTOS-Plus-TCP/source/.*')"
- Format the errors in HTML format so that it is more readable while removing the FreeRTOS-Kernel directory from the report
cov-format-errors --dir . --exclude-files '(.*/FreeRTOS-Kernel/.*)' --html-output html-output
You should now have the HTML formatted violations list in a directory named html-output.
With the current configuration and the provided project, you should see only one deviation from advisory rule 8.13 in file
FreeRTOS_IP.c here.
This deviation has a justification outlined here. With
that justification in place, a coverity suppression statement has been added to the code. However, even with that suppression in
place, the coverity tool continues to report the deviation. Thus, as an exception, we have allowed the deviation to be reported in
the HTML formatted report. If you find a way around it, please help us fix this by creating a pull-request in this repository.