This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: MISRA 10.1 and 10.3 Warning

Tool/software: TI C/C++ Compiler

I am using MISRA-C option with the latest version of the compiler TI V17.3.0.STS.  I have also tried earlier versions of the compiler.

I have a function,

Insert_Checksum_Buffer( &UART_TXD_Buffer[0]  );

which the compiler reports 

Description Resource Path Location Type
#1393-D (MISRA-C:2004 10.1/R) 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 Frames.c /MAP/source MAP line 27 C/C++ Problem

where

uint8_t  UART_TXD_Buffer[64];

and function definition is 

/*--------------------------------------------------------*/
void Insert_Checksum_Buffer(uint8_t *ptr_address)

{

..

}

so i cast as follows,

Insert_Checksum_Buffer( (uint8_t *)(&UART_TXD_Buffer[0])  );

and now i get the warning message,

Description Resource Path Location Type
#1395-D (MISRA-C:2004 10.3/R) The value of a complex expression of integer type shall only be cast to a type of the same signedness that is no wider than the underlying type of the expression Frames.c /MAP/source MAP line 236 C/C++ Problem

How do I code this function without generating any MISRA-C warnings?

I have literally 1000's of these functions in my code that needs to be resolved.

thanks in advance

Rob

  • The compiler should not issue a MISRA diagnostic for this line ...

    Rob Price said:
    Insert_Checksum_Buffer( &UART_TXD_Buffer[0]  );

    So I filed CODEGEN-2238 in the SDOWP system to have this investigated.  You are welcome to follow it with the SDOWP link below in my signature.

    As a workaround write this instead ...

    Insert_Checksum_Buffer(UART_TXD_Buffer);

    Those lines are equivalent.  For some reason, the MISRA check sees them differently.

    Thanks and regards,

    -George

  • thank you for the feedback,  that has resolved the warnings for index [0] references  but i still have a problem with statements that are non zero index.

    Insert_Checksum_Buffer( &UART_TXD_Buffer[1]  );

    Rob

  • I updated CODEGEN-2238 so the case ...

    Rob Price said:
    Insert_Checksum_Buffer( &UART_TXD_Buffer[1]  );

    ... is considered as well.  

    Thanks and regards,

    -George