Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dir 4.14 - How to check pointer to structure
#1
For example:
Code:
typedef struct myStruct{
    int myParam;
} myStruct;

void fcn(myStruct *const ptr)
{
    ptr->myParam = 1;
}

What is the recommended way to check the struct pointer in this function?
<t></t>
Reply
#2
There is no such Directive in MISRA C 2012 (Directive 4.13 is the highest number)?
<t></t>
Reply
#3
This is in Amendment 1: https://www.misra.org.uk/LinkClick.aspx?...D&tabid=57
<t></t>
Reply
#4
Oh, I see.
But i don't think a local pointer classifies as external resource like specified in this particular directive.
If data of type myStruct is received over a communication channel you obviously need some sort of checksum.
<t></t>
Reply
#5
Right.
I think that the problem was that these functions were not being used in the application, so the MISRA check was triggering this.
Now that I really use them in the application, I have no more errors.

Thanks for the feedback!
<t></t>
Reply
#6
The amplification of Directive 4.14 gives a list of the sort of "external sources" that are covered by this directive.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)