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 11.3 in MISRA.md #857

Merged
merged 9 commits into from
Nov 28, 2023

Conversation

chinglee-iot
Copy link
Member

@chinglee-iot chinglee-iot commented Oct 24, 2023

Suppress MISRA C rule 11.3 in MISRA.md

Description

MISRA C:2012 Rule 11.3

A cast shall not be performed between a pointer to object type and apointer to a different object type

MISRA violation
The rule requires not to cast a pointer to object into a pointer to a different object to prevent undefined behavior due to incorrectly aligned. To support static memory allocation,

FreeRTOS creates static type kernel objects which are aliases for kernel object type with prefix "Static" for data hiding purpose. A static kernel object type is guaranteed to have the same size and alignment with kernel object, which is checked by configASSERT. Static kernel object types include StaticEventGroup_t, StaticQueue_t, StaticStreamBuffer_t, StaticTimer_t and StaticTask_t.

The following is one of the violation example:

pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 !e9087 EventGroup_t and StaticEventGroup_t are deliberately aliased for data hiding purposes and guaranteed to have the same size and alignment requirement - checked by configASSERT(). */

Suppress in the PR

  • FreeRTOS supports static allocation. Suppress this rule to allow conversion of static kernel object type to internal kernel object type.

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.

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.

* FreeRTOS supports static allocation. Suppress this rule to allow
  conversion of static structure type to internal structure type.
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f2637ba) 93.64% compared to head (09ac528) 93.64%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #857   +/-   ##
=======================================
  Coverage   93.64%   93.64%           
=======================================
  Files           6        6           
  Lines        3179     3179           
  Branches      885      885           
=======================================
  Hits         2977     2977           
  Misses         95       95           
  Partials      107      107           
Flag Coverage Δ
unittests 93.64% <100.00%> (ø)

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.

@chinglee-iot chinglee-iot requested a review from a team as a code owner October 28, 2023 05:58
queue.c Outdated Show resolved Hide resolved
@chinglee-iot chinglee-iot requested a review from moninom1 October 30, 2023 07:25
moninom1
moninom1 previously approved these changes Oct 30, 2023
Signed-off-by: Gaurav Aggarwal <[email protected]>
aggarg
aggarg previously approved these changes Nov 28, 2023
Copy link

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
0.0% 0.0% Duplication

@aggarg aggarg merged commit dabbc05 into FreeRTOS:main Nov 28, 2023
17 checks passed
@aggarg aggarg deleted the fix-misra-11.3 branch November 28, 2023 13:34
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