From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <julia.lawall@inria.fr>, cocci@inria.fr
Cc: Erick Karanja <karanja99erick@gmail.com>
Subject: Re: [cocci] Searching for questionable call pairs (with SmPL)?
Date: Thu, 24 Jul 2025 18:18:16 +0200 [thread overview]
Message-ID: <a374542e-3ace-4e02-8715-d15ed9afbab1@web.de> (raw)
In-Reply-To: <41b71929-b32d-507d-eff6-ca19ea3c965@inria.fr>
> I would think you should do:
>
> @r exists@
> expression x, y;
> position p1,p2,p3,p4;
> @@
> mutex_lock(x);@p1
> ...
> mutex_lock(y);@p2
> ...
> mutex_unlock(x);@p3
> ...
> mutex_unlock(y);@p4
>
> And then use a python rule to print p1, p2, p3, p4. That way you will keep
> the different matches separated.
Will the following source code search approach trigger more helpful
development considerations?
@find@
expression x, y;
position l1, l2, ul1, ul2;
@@
mutex_lock@l1(x);
...
mutex_lock@l2(y);
<+...
mutex_unlock@ul1(x);
...
mutex_unlock@ul2(y);
...+>
@display@
expression find.x, find.y;
position find.l1, find.l2;
@@
*mutex_lock@l1(x);
...
*mutex_lock@l2(y);
Questionable test result (by the software combination “Coccinelle 1.3.0” for example):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> time /usr/bin/spatch --no-loops ../janitor/show_questionable_unlock_call_order3.cocci qc_audio_offload-handle_uaudio_stream_req-excerpt-20250722.c
…
@@ -70,7 +70,6 @@ static void handle_uaudio_stream_req(str
goto response;
}
- mutex_lock(&chip->mutex);
if (req_msg->enable) {
if (info_idx < 0 || chip->system_suspend || subs->opened) {
ret = -EBUSY;
@@ -103,7 +102,6 @@ static void handle_uaudio_stream_req(str
ret = prepare_qmi_response(subs, req_msg, &resp,
info_idx);
if (ret < 0) {
- mutex_lock(&chip->mutex);
subs->opened = 0;
mutex_unlock(&chip->mutex);
}
@@ -136,7 +134,6 @@ static void handle_uaudio_stream_req(str
}
disable_audio_stream(subs);
- mutex_lock(&chip->mutex);
subs->opened = 0;
mutex_unlock(&chip->mutex);
}
real 0m0,197s
user 0m0,172s
sys 0m0,024s
Regards,
Markus
next prev parent reply other threads:[~2025-07-24 16:18 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 7:45 [cocci] Searching for questionable call pairs (with SmPL)? Markus Elfring
2025-07-24 14:15 ` Markus Elfring
2025-07-24 14:47 ` Julia Lawall
2025-07-24 15:02 ` Markus Elfring
2025-07-24 15:09 ` Julia Lawall
2025-07-24 15:15 ` Markus Elfring
2025-07-24 15:25 ` Julia Lawall
2025-07-24 15:30 ` Markus Elfring
2025-07-24 16:18 ` Markus Elfring [this message]
2025-07-30 12:10 ` Markus Elfring
2025-08-01 7:33 ` Markus Elfring
2025-08-01 8:06 ` Julia Lawall
2025-08-01 8:33 ` Markus Elfring
2025-08-02 10:13 ` [cocci] Searching for lock calls without unlocking " Markus Elfring
2025-08-02 11:18 ` Markus Elfring
2025-08-02 11:28 ` Julia Lawall
2025-08-02 11:51 ` Markus Elfring
2025-08-02 11:54 ` Julia Lawall
2025-08-02 12:02 ` Markus Elfring
2025-08-02 12:10 ` Julia Lawall
2025-08-02 12:56 ` Markus Elfring
2025-08-02 13:05 ` Julia Lawall
2025-08-02 13:33 ` Markus Elfring
2025-08-02 13:45 ` Julia Lawall
2025-08-02 14:06 ` Markus Elfring
2025-08-02 15:43 ` Markus Elfring
2025-08-02 15:46 ` Julia Lawall
2025-08-02 16:01 ` Markus Elfring
2025-08-02 16:04 ` Julia Lawall
2025-08-02 16:18 ` Markus Elfring
2025-08-02 16:24 ` Julia Lawall
2025-08-02 16:35 ` Markus Elfring
2025-08-02 17:38 ` Julia Lawall
2025-08-02 18:11 ` Markus Elfring
2025-08-02 19:12 ` Julia Lawall
2025-08-02 19:26 ` Markus Elfring
2025-08-02 19:35 ` Julia Lawall
2025-08-02 19:42 ` Markus Elfring
2025-08-02 19:44 ` Julia Lawall
2025-08-02 19:48 ` [cocci] Evolution of software documentation? Markus Elfring
2025-08-03 5:24 ` [cocci] Searching for lock calls without unlocking (with SmPL)? Markus Elfring
2025-08-03 5:34 ` Julia Lawall
2025-08-03 5:55 ` Markus Elfring
2025-08-03 7:55 ` Markus Elfring
2025-08-04 10:55 ` [cocci] Searching for questionable call pairs " Markus Elfring
2025-08-04 11:25 ` [cocci] Searching for lock calls without unlocking " Markus Elfring
2025-08-06 9:30 ` [cocci] Searching for repeated actions " Markus Elfring
2025-07-24 18:37 ` [cocci] Searching for questionable call pairs " Markus Elfring
2025-07-25 7:06 ` Markus Elfring
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=a374542e-3ace-4e02-8715-d15ed9afbab1@web.de \
--to=markus.elfring@web.de \
--cc=cocci@inria.fr \
--cc=julia.lawall@inria.fr \
--cc=karanja99erick@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.