Hello Jörg,
On 07/20/2011 02:28 PM, Joerg-Cyril.Hoehle@t-systems.com wrote:
wouldn't it be possible to add a function to the static checkers to be able to detect static functions whose return is systematically ignored and rewrit these and their callers to use void? I came across another occurence of that pattern no later than yesterday (mcimidi IIRC).
that can be done in theory with coccinelle. The devil is in the implementation details. The basic idea is simple (think set operations). rule1: Find all the function calls in the file that use the return value rule2: Find the static function declaration/definitions and happen to have a function name found in rule1. Mark them as good. rule3: Change the return type of all the other static functions to void. The callers of those functions need no change; they ignore the return value anyway.
Of course the above rules can expand to multiple real coccinelle rules and multiple alternations. Especially finding the "return value is used" case will require a few different matches.
I'll have a go at it but I can't promise as I'm freaking busy lately.
bye michael