Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Aggarwal <[email protected]>
  • Loading branch information
aggarg committed Nov 28, 2023
1 parent 6060be6 commit 8c2503c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions MISRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ _Ref 8.4.1_

_Ref 11.3.1_

- MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to object
type and a pointer to a different object type.
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.
- MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to
object type and a pointer to a different object type.
This rule prohibits casting a pointer to object into a pointer to a
different object because it may result in an incorrectly aligned pointer,
leading to undefined behavior. Even if the casting produces a correctly
aligned pointer, the behavior may be still undefined if the pointer is
used to access an object. FreeRTOS deliberately creates external aliases
for all the kernel object types (StaticEventGroup_t, StaticQueue_t,
StaticStreamBuffer_t, StaticTimer_t and StaticTask_t) for data hiding
purposes. The internal object types and the corresponding external
aliases are guarnteed to have the same size and alignment which is
checked using configASSERT.


### MISRA configuration
Expand Down

0 comments on commit 8c2503c

Please sign in to comment.