/* >>>------------------------------------------------------------ * * File: rule_16.7.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 16.7 (Advisory): * 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. * * Implemented by message: * 3673 The object addressed by the pointer parameter '%s' is * not modified and so the pointer could be of type * 'pointer to const'. * * <<<------------------------------------------------------------ */ /* PRQA S 2982,2983,3203 ++ */ #include "misra.h" #include "m2cmex.h" static S16 test_1607a( S16 pba[], S16 pbb[], S16 pbc[], S16 pbd[], S16 pbe[], const S16 * const p ); static void test_1607b( S16 *x ); static S16 test_1607c( const S16 *x ); extern S16 test_1607( void ) { const S16 ci = 99; S16 ba[3] = { 1, 2, 3 }; S16 bb[3] = { 1, 2, 3 }; S16 bc[3] = { 1, 2, 3 }; S16 bd[3] = { 1, 2, 3 }; S16 be[3] = { 1, 2, 3 }; S16 r; r = test_1607a( ba, bb, bc, bd, be, &ci ); return r; } static S16 test_1607a( S16 pba[], S16 pbb[], /* MISRA Violation */ S16 pbc[], /* MISRA Violation */ S16 pbd[], S16 pbe[], /* MISRA Violation */ const S16 * const p ) { S16 r; S16 *pnc; const S16 *pc; r = pba[ 1 ] + pbb[ 1 ] + pbc[ 1 ]; test_1607b( pba ); /* Prototype indicates pba is an output parameter */ r = test_1607c( pbb ); pnc = pbd; /* pbd is addressed by a pointer to non-const */ *pnc = 1; pc = pbe; /* pbe is addressed by a pointer to const */ r = *p; return r; } static void test_1607b( S16 *x ) { *x = 0; return; } static S16 test_1607c( const S16 *x ) { return *x; }