Running SonarQube 9.6.1.59531 with SonarScanner 4.7.0.2747.
We have multiple handler functions of type func(param1, __attribute__ ((unused)) param2) - some of them read param2, some modify its contents, others do not use it at all but they have the same prototype since they are expected to work in highly similar contexts. SonarQube raises issue S995 - Make the type of this parameter a pointer-to-const. - for the field that is marked as unused and does not appear in the function body - see the following example:
int S995_trigger(int a, __attribute__ ((unused)) char *b) {
printf("S995 trigger %d\n", a);
}
will raise “Make the type of this parameter a pointer-to-const. The current type of “b” is “char *”.”
Is this the intended behavior of the rule? Since it was inspired by MISRA I assume the “unused” attribute wasn’t considered for these situations. Is there a different rule allowing us to obtain the same results but which considers the gcc attribute extensions?