简体   繁体   English

MISRA C 违反指令 4.14

[英]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.即使我正在检查 NULL 指针,我仍然违反了 Misra 4.14 I,e...应检查来自外部来源的值的有效性。

How to fix above warning?如何解决上述警告?

Your code does not violate MISRA-C:2012 rule 14.4 (note the spelling).您的代码不违反 MISRA-C:2012规则 14.4 (注意拼写)。

A violation of that rule would be to write if(Data) instead of if(Data != NULL) .违反该规则是编写if(Data)而不是if(Data != NULL) The former violates 14.4, the latter is MISRA-C compliant.前者违反 14.4,后者符合 MISRA-C。

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.然而,指令 4.14 (注意拼写)应检查从外部来源接收的值的有效性,指令已通过第一次修订 AMD-1 添加到 MISRA-C:2012 中。 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.该指令是关于清理来自外部来源的输入,例如文件、用户输入、通信渠道等。它与您的问题完全无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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