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 warning (MISRA-C:2004 16.7/A) Misreported

Hi,

CGT 4.7.1

 

 (MISRA-C:2004 16.7/A) A pointer parameter in a function prototype should be declared as pointer to const if the pointer is not used to modify the addressed object ("ptrToMyStruct: const myStruct_T *")

In the following code I get MISRA 16.7 falsely reported on the terminating brace of function myFunc. As you can see, the pointer is used to modify the addressed object and so 16.7 should not be reported.

typedef struct
{
    int a;
    int b;
} myStruct_T;
 
myStruct_T myStructModule = { 1, 3 };
 
void myFunc(myStruct_T *ptrToMyStruct);
 
void myFunc(myStruct_T *ptrToMyStruct)
{
    *ptrToMyStruct = myStructModule;
}
 
void main(void)
{
    myStruct_T myStructLocal = { 0, 0 };

    myFunc(&myStructLocal);
}