MISRA C:2012 Dir 4.8
If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden
Description
Rule Definition
If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden.
Rationale
If a pointer to a structure or union is not dereferenced in a file, the implementation details of the structure or union need not be available in the translation unit for the file. You can hide the implementation details such as structure members and protect them from unintentional changes.
Define an opaque type that can be referenced via pointers but whose contents cannot be accessed.
Polyspace Implementation
If a structure or union is defined in a file or a header file included in the file, a pointer to this structure or union declared but the pointer never dereferenced in the file, the checker flags a coding rule violation. The structure or union definition should not be visible to this file.
If you see a violation of this rule on a structure definition, identify if you have defined a pointer to the structure in the same file or in a header file included in the file. Then check if you dereference the pointer anywhere in the file. If you do not dereference the pointer, the structure definition should be hidden from this file and included header files.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Code design |
Category: Advisory |
AGC Category: Advisory |
Version History
Introduced in R2018a