MISRA.VAR.NEEDS.CONSTVariable is not modified but is declared without const qualifier. MISRA-C++ Rule 7—1—1 (required): A variable which is not modified shall be const qualified.RationaleIf a variable does not need to be modified, then it shall be declared with const qualification so that it cannot be modified. A non-parametric variable will then require its initialization at the point of declaration. Also, future maintenance cannot accidentally modify the value. Examplevoid b ( int32_t * ); int32_t f ( int32_t * p1, // Non-compliant int32_t * const p2, // Compliant int32_t * const p3 ) // Compliant { *p1 = 10; *p2 = 10; b( p3 ); int32_t i = 0; // Non-compliant return i; } |