[cocci] Reproducing a known patch with SmPL?
Markus Elfring <[email protected]> Sun, 1 Mar 2026 14:50:50 +0100
| Newsgroups | fr.inria.cocci |
|---|---|
| Message-ID | <[email protected]> |
Hello, I proposed another source code adjustment for a selected function implementation according to the development branch “Linux next-20260226”. [PATCH] i3c: dw: Use more common code in dw_i3c_master_i2c_xfers() https://lore.kernel.org/lkml/[email protected]/ https://lkml.org/lkml/2026/2/27/700 I tried the following SmPL script variant out also together with the software combination “Coccinelle 1.3.1” accordingly. @adjustment exists@ expression action, context, last_action; expression list el; identifier member, rc; @@ { ... { ... - action(context); - return rc + goto target ; } ... + last_action(el); rc = context->member; +target: action(context); - last_action(el); return rc; } Questionable test result: Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch …/Projekte/Coccinelle/janitor/use_more_common_code.cocci drivers/i3c/master/dw-i3c-master.c … @@ -1672,9 +1672,7 @@ err_disable_pm: pm_runtime_dont_use_autosuspend(&pdev->dev); err_assert_rst: - reset_control_assert(master->core_rst); - - return ret; + goto target; } EXPORT_SYMBOL_GPL(dw_i3c_common_probe); real 0m0,582s user 0m0,539s sys 0m0,033s * Why was a source code place shown here at all which does not contain a variable assignment before an interesting function call? * How should the data processing be improved in more desirable ways? Regards, Markus