Reputation: 11
The validity of values received from external sources shall be checked
int fun (uint8 * Data)
{
if (Data != NULL) {
*Data = 0x00u;
return(E_OK);
}
}
Does any body have any idea how to fix above warning? Even though I am checking the NULL pointer still I am getting the violation of Misra 4.14 I,e...validity of values from external sources shall be checked.
How to fix above warning?
Upvotes: 0
Views: 2323
Reputation: 213428
Your code does not violate MISRA-C:2012 rule 14.4 (note the spelling).
A violation of that rule would be to write if(Data)
instead of if(Data != NULL)
. The former violates 14.4, the latter is MISRA-C compliant.
Edit:
There is however a directive 4.14 (note the spelling) The validity of values received from external sources shall be checked, which was added to MISRA-C:2012 with the first amendment AMD-1. That directive is regarding sanitizing input from external sources such as files, user input, communication channels etc. It has absolutely nothing to do with your question.
Upvotes: 1