Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
10.1 Non-constant value to function
#1
Hey,

i have a problem with these 10.1 Rule:

Code:
void foo_bar(uint32_t u32)      /* another function to do something */

void test_func(uint8_t u8)
{
   uint32_t u32Convert = (uint32_t)u8;
   ...
   foo_bar(u32Convert);      /*Error - Note 960 Violates MISRA 2004 Required Rule 10.1, Prohibited Implicit Conversion: Non-constant argument to function */
   ...
}
MISRA says that a expression, which is a function argument, shouldn't be converted to a underlying type.
But i took a 8 bit value, expand to 32bit and use this for the function. The type of u32Convert is uint32_t as it should be for the function argument of foo_bar.
Is it neccessary to know what foo_bar does with the value?

Thanks for your help!
Greetz,
<t></t>
Reply
#2
There is no implicit conversion taking place on the function call. The argument u32Convert has type uint32_t and the function prototype on the first line (which is missing a semi-colon) declares the parameter u32 also to have type uint32_t.

It appears that your tool is incorrectly diagnosing a violation of Rule 10.1
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)