>> @addition@ >> expression object; >> @@ >> object = kzalloc(...) >> ... when any >> device_unregister(...); >> out: >> +kfree(object); >> return ERR_PTR(...); > > There is no reason why a patch should be generated in this case.
We come along different software development views also for this use case. I tend still to interpret some of my source code search patterns in other directions. > As you should know well, A ... B only matches in a transformation case > if every path from A leads to code matching B. Now I imagine that an explanation of such information can become more interesting also based on the applied technologies as a knowledge background. https://github.com/coccinelle/coccinelle/blob/ed1eb8e06f800739d3992158d36945c0c4c6f0c7/docs/manual/cocci_syntax.tex#L860 https://en.wikipedia.org/wiki/Computation_tree_logic#Relations_with_other_logics > That is not the case in your example. The shown SmPL script can probably indicate that a return statement should occasionally be executed if a jump to it (according to the label “out” for example) was performed before (in one if branch). The following simple transformation approach seems to work also in the way which I expected somehow initially. @addition@ expression object; @@ object = kzalloc(...) ... when exists device_unregister(...); out: +kfree(object); return ERR_PTR(...); Can any extensions for the software documentation help to make the application of the semantic patch language easier and safer finally? Regards, Markus _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
