Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 17.4 - array elements contained inside structure def
#1
• MISRA C rule 17.4 says arithmetic operations shall not be performed on pointers, as they may result into referencing to non-existing addresses.
• Alternative to this is to catch a pointer being received as an argument into the respective type of an array, for e.g. catch ‘&arr’ into ‘arr[]’, and use array indexing to access its elements. This works well for pointers of basic data types.
• Problem arises in the case of accessing array elements contained by a structure.
• e.g.
struct message
{
int address;
int length;
int data[50];
}m1,m2;

• Now, the statement “source_node = m1.data[SOURCE_NODE_INDEX]” triggers this 17.4 non-compliance note.
• This happens when accessing only the array elements, and not for single variables of a structure definition.
• So the question I have is, what is the best way to access individual array elements contained inside a structure definition?
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)