Avoiding “ignorance” of return values for pass-through functions?
Some functions return an input parameter after desired data processing was performed.
Thus it is known because of this special property that the results from such function calls do not need to be checked.
Some programmers got used to specify these function calls as separate statements.
This has got the consequence that the source code could eventually be interpreted in the way that provided return values are not used (because previous variables would be applied instead).
It is possible to move such a function call into a parameter of a subsequent function call.
How do you think about to apply a transformation with the help of the semantic patch language like the following?
@Replacement@
expression action, input1, input2, input3, target;
identifier gs;
@@
-\(g_string_assign@gs
-\|g_string_append@gs
-\|g_string_append_c@gs
-\|g_string_append_unichar@gs
-\|g_string_prepend@gs
-\|g_string_prepend_c@gs
-\|g_string_prepend_unichar@gs
-\) (target, input1);
action (
+ gs (
target
+ , input1)
, input2, input3
);