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

Suppress MISRA C rule 21.6 in MISRA.md #858

Closed

Conversation

kar-rahul-aws
Copy link
Member

@kar-rahul-aws kar-rahul-aws commented Oct 24, 2023

This PR suppresses MISRA C rule 21.6 in MISRA.md.

Description

MISRA C:2012 Rule 21.6

The Standard Library input/output functions shall not be used.

MISRA violation

FreeRTOS Kernel uses snprintf to print out the buffer in vTaskListTasks and vTaskGetRunTimeStatistics API.

iSnprintfReturnValue = snprintf( pcWriteBuffer,
                                 uxBufferLength - uxConsumedBufferLength, 
                                 "\t%c\t%u\t%u\t%u\r\n",
                                 cStatus,
                                 ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority,
                                 ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark,
                                 ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );

Fix in this PR

  • We are suppressing this rule to allow use of snprintf library.

Test Steps

N/A

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.

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

@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a8650b9) 93.64% compared to head (6cebd01) 93.64%.
Report is 6 commits behind head on main.

❗ Current head 6cebd01 differs from pull request most recent head da472ab. Consider uploading reports for the commit da472ab to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #858   +/-   ##
=======================================
  Coverage   93.64%   93.64%           
=======================================
  Files           6        6           
  Lines        2549     2549           
  Branches      608      608           
=======================================
  Hits         2387     2387           
  Misses        107      107           
  Partials       55       55           
Flag Coverage Δ
unittests 93.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

MISRA.md Outdated
@@ -67,6 +67,10 @@ Copy below content to `misra.conf` to run Coverity on FreeRTOS-Kernel.
deviation: "Rule 11.5",
reason: "Allow casts from `void *`. List owner, pvOwner, is stored as `void *` and are cast to various types for use in functions."
}
{
deviation: "Rule 21.6",
reason: "snprintf is used in APIs vTaskListTasks and vTaskGetRunTimeStatistics to print the buffer."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a little more details, something like this https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-216

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@kar-rahul-aws kar-rahul-aws requested a review from a team as a code owner November 1, 2023 16:38
Copy link

sonarqubecloud bot commented Nov 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@kar-rahul-aws
Copy link
Member Author

Closing this, since a new PR achieving the same result is created

@kar-rahul-aws kar-rahul-aws deleted the suppress_misra_21_6 branch February 1, 2024 09:45
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.

2 participants