Page 1 of 1

MISRA 11.2

Posted: Wed Apr 10, 2013 10:36 am
by spd123
Hi,

[ MISRA 11.2 ] Conversions shall not be performed between a pointer to object and any type, other than an integral type, another pointer to object type or a pointer to void.

I am using cystal revs for C MISRA C 2004 compliance.
Its showing violation in following code. pl. suggest solution for this.
cal_table F32 xdata cal_table[10];
here F32 is float.

Main.c
--------------
*( ( ( U8 * )&cal_table[ 0 ] ) + 0U ) = 0U;

if( ( command_str[ 2 ] == SNS_ID1 ) && ( command_str[ 3 ] == SNS_ID1 ) ) // SNS_ID1 is constant

*( ( ( U8 * )&cal_table[ i ] ) + ch ) = ASCII_Int( command_str + 10U, 3U );

ch = *( ( ( U8 * )&cal_table[ i ] ) + ch );

spi_write( ( U8 )AX5031_REG_PLLLOOP, ( U8 )AX5031_VAL_PLLLOOP ); //AX5031_REG_PLLLOOP & AX5031_VAL_PLLLOOP are constats.

Re: MISRA 11.2

Posted: Tue Apr 16, 2013 3:33 pm
by misra-c
The code example does not appear to contain any violations of Rule 11.2 so you might want to discuss any such reported violations with your tool supplier.

The code does however violate advisory Rule 11.4 because an expression with type "pointer to float" is converted to "pointer to U8", for example in:

Code: Select all

( U8 * )&cal_table[0]