FreeRTOS-Kernel/examples/coverity
Guilherme Giácomo Simões e81ad46b0e
refactor: change methods ENTER|EXIT critical (#1140)
refactor: change methods ENTER|EXIT critical

The read and write of BaseType_t are atomic for a number of ports
and therefore, do not require taskENTER_CRITICAL/taskEXIT_CRITICAL.
This PR introduces portBASE_TYPE_ENTER_CRITICAL and
portBASE_TYPE_EXIT_CRITICAL which default to  taskENTER_CRITICAL
and taskEXIT_CRITICAL. The APIs that read/write BaseType_t are updated
to use these new macros. 

The next change would to be to define portBASE_TYPE_ENTER_CRITICAL and
portBASE_TYPE_EXIT_CRITICAL to nothing for ports where BaseType_t 
read and write are atomic.

Signed-off-by: guilherme giacomo simoes <trintaeoitogc@gmail.com>
2024-10-07 10:37:50 +05:30
..
CMakeLists.txt Adding SMP coverity example (#1039) 2024-04-19 10:18:00 +05:30
coverity_misra.config Fix small bugs in Kernel (#998) 2024-02-20 22:19:41 +05:30
FreeRTOSConfig.h Use Regex for Copyright Year in Header Check (#1002) 2024-02-26 09:26:42 -08:00
README.md refactor: change methods ENTER|EXIT critical (#1140) 2024-10-07 10:37:50 +05:30

MISRA Compliance for FreeRTOS-Kernel

FreeRTOS-Kernel is MISRA C:2012 compliant. This directory contains a project to run Synopsys Coverity for checking MISRA compliance.

Note

Coverity version 2023.6.1 incorrectly infers the type of pdTRUE and pdFALSE as boolean because of their names, resulting in multiple false positive warnings about type mismatch. We replace pdTRUE with pdPASS and pdFALSE with pdFAIL to avoid these false positive warnings. This workaround will not be needed after Coverity fixes the issue of incorrectly inferring the type of pdTRUE and pdFALSE as boolean.

Deviations from the MISRA C:2012 guidelines are documented in MISRA.md and coverity_misra.config files.

Getting Started

Prerequisites

Coverity can be run on any platform mentioned here. The following are the prerequisites to generate coverity report:

  1. CMake version > 3.13.0 (You can check whether you have this by typing cmake --version).
  2. GCC compiler.
    • See download and installation instructions here.
  3. Clone the repo using the following command:
    • git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git ./FreeRTOS-Kernel

Generating Report

Go to the root directory of the FreeRTOS-Kernel repo and run the following commands in a terminal:

  1. Update the compiler configuration in Coverity:
cov-configure --force --compiler cc --comptype gcc
  1. Create the build files using CMake in a build directory:

Singe core FreeRTOS:

cmake -B build -S examples/coverity

SMP FreeRTOS:

cmake -B build -S examples/coverity -DFREERTOS_SMP_EXAMPLE=1
  1. Build the (pseudo) application:
cd build/
cov-build --emit-complementary-info --dir cov-out make coverity
  1. Go to the Coverity output directory (cov-out) and begin Coverity static analysis:
cov-analyze --dir ./cov-out \
  --coding-standard-config ../examples/coverity/coverity_misra.config \
  --tu-pattern "file('[A-Za-z_]+\.c') && ( ! file('main.c') ) && ( ! file('port.c') )"
  1. Generate the HTML report:
cov-format-errors --dir ./cov-out --html-output html-output

HTML report should now be generated in a directory named html-output.