Hi Sonar guys,
In C, we think that rule c:S855 (Function pointers should not be converted to any other type) should not trigger when args/return types are promoted to void *.
Example:
typedef (int) (*my_func_t) (size_t sz, const void *input, void *output);
int some_func(size_t sz, const uint8_t *input, uint8_t *output) {
...
}
my_func_t f = (my_func_t) some_func; // triggers c:S855
This kind of error happens when you have an external “framework” that expects a table of functions. Because it is generic it cannot enforce the types of input
and output
.
You can workaround this by keeping the void *
signature in your func and performing a cast inside it, but we think it is worth skipping this rule on void *
promotion.
Regards