In MISRA-C:2004 rule 17.4 there was an advisory rule banning all forms of pointer arithmetic. The intent was good, the purpose of the rule was an attempt to ban potentially dangerous code such as:
stuff* p;
p = p + 5; // 5 stuff, not 5 bytes, bug or intentional?
and hard-to-read code such as
*(p + 5) = something; // harder to read but equivalent to p[5]
Generally, the intention is to recommend using an integer iterator instead of pointer arithmetic, when looping through pointed-to data.
However, the rule also banned various fundamental pointer operations that are likely not dangerous, for example ptr++
. Generally, the rule was far too strict.
In MISRA-C:2012 this rule (18.4) was relaxed to only ban the + - += -=
operators.
In your case, the buffPtr = &buffPtr[1];
was a misguided attempt to dodge rule 17.4, because the rule didn't make much sense. Instead the programmer decided to obfuscate their program, making it less readable and therefore less safe.
The correct way to deal with this would be to use the ++ operator and ignore rule 17.4. It is an advisory rule, so no deviation needs to be done (unless the local MISRA-C implementation for some reason says otherwise). If you do need to deviate, you could simply say that the rule doesn't make any sense for the ++ operator and then refer to MISRA-C:2012 18.4.
(Of course, rewriting the whole loop to a for loop as shown in another answer is the best solution)
Programming without using common sense is always very dangerous, as is blindly following MISRA without understanding the sound rationale behind the rules, or in this case the lack of such.