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.

MISRA-C Rule 10.1 Misreported by MSP430 C Compiler

I am using CCS v5.1.0.09000 with MSP430 C compiler v4.0.0.  The following code produces an error on the indicated lines and states MISRA rule 10.1 ("The value of an expression of integer type shall not be implicitly converted to a different underlying type if it is not a conversion to a wider integer type of the same signedness") as the reason.  The error stays with the line containing the function call, so I think the compiler has a problem with the return value of Uart_WriteByteArray().  The curious part about this bug is that it depends on the size of the second parameter.

Thanks, Austin

 

From header file:
typedef enum UartError
{
    UartError_OK,
    UartError_NO_DATA,
    UartError_BUFFER_FULL
} UartError_t;

typedef enum UartPort
{
    UartPort_0 = 0u,
    UartPort_1 = 1u,
    UartPort_2 = 2u,
    UartPort_3 = 3u
} UartPort_t;

extern UartError_t Uart_WriteByteArray(
    UartPort_t port,
    uint16_t numToWrite,
    const uint8_t source[]);

Code:

{
    static uint8_t junk[300];
    const uint16_t length = 30u;
    UartError_t error;

    error = Uart_WriteByteArray(    /* MISRA 10.1 error reported */
                UartPort_1,
                300u,
                junk);

    error = Uart_WriteByteArray(    /* okay */
                UartPort_1,
                30u,
                junk);

    error = Uart_WriteByteArray(    /* MISRA 10.1 error reported */
                UartPort_1,
                length,
                junk);

    if (error == UartError_OK)
    {
        _no_operation();
    }
}

  • Thank you for this test case.  I can reproduce the problem.  I don't see why those diagnostics are emitted.  I submitted SDSCM00042447 in the SDOWP system to have this fixed.  Feel free to track it with the SDOWP link below in my sig.

    Thanks and regards,

    -George