![]() |
![]() |
3673 | ![]() |
||||
![]() | |||||||
| Pointers | |||||||
This function parameter is a pointer which is never used to modify the data which it addresses. In other words, it is an "input" parameter. It would therefore improve clarity to declare it as a pointer to a const qualified type. Consistent use of the const type qualifier can help to improve clarity and protect against possible misuse of objects. For example:
/*PRQA S 506,553,2017,3227,3408 ++*/
extern void foo (
int *pir, /* Message 3673 */
int *piw ) /* No message */
{
int x;
x = *pir; /* pir is used for input */
*piw = x; /* piw is used for output */
}
MISRA-C:2004 Rules applicable to message 3673:
| Rule 16.7 (Advisory) | A pointer parameter in a function prototype should be declared as pointer to const if the pointer is not used to modify the addressed object. |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |