Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About 17.4 Question?
#3
There are a number of issues with this example as written.
  • The line "PrErrLog = (uint16 *)Err;" violates rule 11.4.
  • Cast is to uint16 not Uint16
  • Pointer increment is not consistent, but varies from 0 to SizeErrLog. So the accessed items are 0, 1, 3, 6 ...
  • Using a non-character pointer to access a struct whose members are of different sizes is not a good idea. Accessing using a non-character pointer is implementation dependent
In some circumstances it might be appropriate to access a structure using a pointer. In those cases a deviation is required for this rule. An example of the issues that need to be considered when deviating this rule ( and rule 17.1) can be found in
"MISRA C:2004 Permits Deviation permits for MISRA Compliance"
which are available from the "MISRA resources" section of the MISRA forum (http://www.misra.org.uk/forum/viewtopic.php?t=1562).

The MISRA working group can not give advice on particular coding design issues.
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)