MISRA 11.2

6.11 Pointer Type Conversions

Moderators: misra-c, david ward

spd123
Posts: 2
Joined: Tue Apr 09, 2013 2:23 pm
Company: Komoline Aerospace Ltd.

MISRA 11.2

Postby spd123 » Wed Apr 10, 2013 10:36 am

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.

misra-c
Posts: 539
Joined: Thu Jan 05, 2006 1:11 pm

Re: MISRA 11.2

Postby misra-c » Tue Apr 16, 2013 3:33 pm

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]
---
Posted by and on behalf of
the MISRA C Working Group


Return to “6.11 Pointer Type Conversions”

Who is online

Users browsing this forum: No registered users and 1 guest