简体   繁体   中英

MISRA C violation Directive 4.14

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM