From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr, kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
"Heiko Stübner" <heiko@sntech.de>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Ulf Hansson" <ulf.hansson@linaro.org>
Subject: Re: Generalising a transformation with SmPL?
Date: Sat, 14 Sep 2024 16:40:49 +0200 [thread overview]
Message-ID: <300b5d1a-ab88-4548-91d2-0792bc15e15e@web.de> (raw)
In-Reply-To: <186de981-7a3c-4fdb-8911-8dfee597c759@web.de>
…
> I found it easy to convert it also into the following small script variant
> for the semantic patch language (Coccinelle software).
>
>
> @adjustment@
> expression e, x;
> @@
> +of_node_put(e);
> if (...)
> {
> <+... when != e = x
> - of_node_put(e);
> ...+>
> }
> -of_node_put(e);
>
>
> 58 patches were accordingly generated for source files of the software “Linux next-20240913”.
…
This SmPL script references a known function name.
https://elixir.bootlin.com/linux/v6.11-rc7/source/drivers/of/dynamic.c#L43
I imagine that it can become helpful to avoid duplicate function calls
also in combination with other functions.
But there are development challenges to consider for functions like mutex_unlock()
which get addresses passed for data structure members.
Thus I hoped that something can be achieved with the following script variant.
@extended_adjustment@
expression e, f, x, y;
@@
+f(e);
if (...)
{
<+... when != \( e = x \| y(..., &e, ...) \)
( f(&e);
|
- f(e);
)
...+>
}
(f(&e);
|
-f(e);
)
But the software combination “Coccinelle 1.2-00038-g2297fc0f” points details out
for further development considerations.
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> spatch drivers/pmdomain/rockchip/pm-domains.c …/Projekte/Coccinelle/janitor/avoid_duplicate_function_call.cocci
…
previous modification:
<<< f(e);
CONTEXT
According to environment 2:
extended_adjustment.e -> pmu->mutex
extended_adjustment.f -> mutex_unlock
current modification:
<<< f(e);
CONTEXT
According to environment 2:
extended_adjustment.e -> &pmu->mutex
extended_adjustment.f -> mutex_unlock
exn while in timeout_function
extended_adjustment: already tagged token:
C code context
File "drivers/pmdomain/rockchip/pm-domains.c", line 538, column 1, charpos = 14292
around = 'if',
whole content = if (rockchip_pmu_domain_is_on(pd) != power_on) {
How can such a software situation be improved?
Regards,
Markus
prev parent reply other threads:[~2024-09-14 14:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-25 18:31 [PATCH] pmdomain: rockchip: Simplify dropping OF node reference Krzysztof Kozlowski
2024-08-25 18:52 ` Heiko Stübner
2024-09-13 12:01 ` Ulf Hansson
2024-09-13 13:16 ` Markus Elfring
2024-09-14 14:40 ` Markus Elfring [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=300b5d1a-ab88-4548-91d2-0792bc15e15e@web.de \
--to=markus.elfring@web.de \
--cc=cocci@inria.fr \
--cc=heiko@sntech.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®