简体   繁体   English

Misra C规则10.1-错误肯定警告?

[英]Misra C rule 10.1 - false positive warning?

My CCS 6.1 ARM compiler (for LM3Sxxxx Stellaris) throws a warning: 我的CCS 6.1 ARM编译器(用于LM3Sxxxx Stellaris)抛出警告:

"MISRA Rule 10.1. The value of an expression of integer type shall not be implicitly converted to a different underlying type if the expression is not constant and is a function argument" “ MISRA规则10.1,如果整数类型的表达式不是常量并且是函数参数,则不应将其隐式转换为其他基础类型”

for following code: 对于以下代码:

static uint32_t diagBaseAddress;

void diagCbGetBaseAddress(uint32_t * addr);

...
diagCbGetBaseAddress(&diagBaseAddress); // line where warning is issued
...

I don't see a problem in my code. 我的代码中没有看到问题。 Is it false positive or my bug? 是误报还是我的错误?

Yes, it is a false positive. 是的,这是错误的肯定。 Rule 10.1 of MISRA-C:2004 is concerned about implicit type promotions of integer types. MISRA-C:2004的规则10.1与整数类型的隐式类型提升有关。 Pointers have nothing to do with that rule. 指针与该规则无关。

Though make sure that none of the adjacent code lines contain the actual problem, the tool could simply be pointing at the wrong line. 尽管确保相邻的代码行均不包含实际问题,但该工具可能只是指向错误的行。

(I can tell it is the 2004 version because it mentions underlying type. In the 2012 version, the concept of underlying type was replaced.) (我可以说它是2004版本,因为它提到了基础类型。在2012年版本中,基础类型的概念被替换了。)

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

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