Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MISRA violations for Kernel release V11.2.0 #1251

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

kar-rahul-aws
Copy link
Member

Description

This PR addresses the MISRA C 2012 violations for Kernel release V11.2.0
The following rules are fixed / suppressed:

  1. Rule 1.2 - Language extension __attribute__ cannot be used. ( suppressed )
  2. Rule 14.3 - Controlling expressions shall not be invariant ( suppressed )
  3. Rule 17.12 - A function identifier should only be used with either a preceding '&' (address-of operator) or with a parenthesized parameter list ( Fixed )
  4. FORWARD_NULL - This is not a MISRA violation , but a C coding standard, where a NULL pointer should not be dereferenced. This is of high severity, hence a NULL check has been added instead of suppressing it.

Test Steps

Run the following steps

cmake -B build -S examples/coverity
cd build
cov-build --config ../covConfig/coverity.xml --emit-complementary-info --dir cov-out make coverity
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') )"
cov-format-errors --dir ./cov-out --html-output html-output

The following output is produced

Attempting to detect unconfigured compilers in build
|0----------25-----------50----------75---------100|
****************************************************
Emitted 10 C/C++ compilation units (100%) successfully

10 C/C++ compilation units (100%) are ready for analysis
The cov-build utility completed successfully.
Coverity Static Analysis version 2024.6.1 on Linux 5.15.0-1077-aws x86_64
Internal version numbers: d59b675bea p-2024.6-push-53

Using 4 workers as limited by CPU(s)
Looking for translation units
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Computing links for 7 translation units
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Computing virtual overrides
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Computing callgraph
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Topologically sorting 237 functions
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Preparing for source code analysis
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Running Sigma analysis
[STATUS] Computing node costs
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Running analysis
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Exporting summaries
|0----------25-----------50----------75---------100|
****************************************************
[STATUS] Computing callgraph metrics for 233 functions
|0----------25-----------50----------75---------100|
****************************************************
Analysis summary report:
------------------------
Files analyzed                       : 24 Total
    C                                : 24
Total LoC input to cov-analyze       : 18184
Functions analyzed                   : 209
Classes/structs analyzed             : 23
Paths analyzed                       : 7539
Time taken by analysis               : 00:00:13
Defects/Coding rule violations found : 51 Total
                                       16 MISRA C-2012 Directive 4.7
                                        2 MISRA C-2012 Rule 11.1
                                       11 MISRA C-2012 Rule 11.3
                                       20 MISRA C-2012 Rule 11.5
                                        1 MISRA C-2012 Rule 8.4
                                        1 OVERRUN

Processing 0 errors.

0%   10   20   30   40   50   60   70   80   90   100%
|----|----|----|----|----|----|----|----|----|----|
Processed errors.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kar-rahul-aws kar-rahul-aws requested a review from a team as a code owner February 27, 2025 10:11
@kar-rahul-aws kar-rahul-aws merged commit 3fd7f17 into FreeRTOS:main Feb 28, 2025
17 checks passed
@kar-rahul-aws kar-rahul-aws deleted the fix_misra_violations branch February 28, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants