Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 14.2 and system level
#2
Code:
== file1.c ==
void fn ( int32_t *ptr )
{
   *ptr = 10;
}

== file2.c ==
extern void fn ( int32_t *ptr );  /* extern should be in header file */

void loop ( void )
{
  for ( int32_t i = 0; i < 10; i++  )
  {
    fn( &i );
  }
}
The above example is not compliant with rule 14.2 because fn assigns a value to "i" in the body of the loop. This can only be determined if the definition of fn is analysed. Therefore a system analysis containing file1.c and file2.c is required.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)