Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question for Rule8.13
#2
Rule 8.13 covers all pointers, which includes the "pointer parameter to function" that was covered by rule 16.7 in MISRA-C:2004.

It was felt that programmers should be encouraged to use const where possible and not just on function parameters.
Code:
int32_t fn ( int32_t *ptr )  /* not compliant */
{
   int32_t *myptr = ptr;     /* not compliant */
   return *myptr;
}

int32_t fn2 ( const int32_t *ptr2 )  /* compliant */
{
   const int32_t *myptr2 = ptr2;     /* compliant */
   return *myptr2;
}
Posted by and on behalf of the MISRA C Working Group


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)