All of lore.kernel.org
 help / color / mirror / Atom feed
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 lock calls without unlocking (with SmPL)?
Date: Sat, 2 Aug 2025 20:11:52 +0200	[thread overview]
Message-ID: <a86ce687-61a5-4e52-92fa-6a0d53db9360@web.de> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2508021935250.3428@hadrien>



Am 02.08.25 um 19:38 schrieb Julia Lawall:
> 
> 
> On Sat, 2 Aug 2025, Markus Elfring wrote:
> 
>>>>>>>      The one in the if is matching with the call closest to it,
>>>>>>
>>>>>> I interpret this hit as a false positive.
>>>>>> (The first lock call in the if branch is not the relevant companion call
>>>>>> from the function implementation.)
>>>>>>
>>>>>>
>>>>>>>                                                                 not the
>>>>>>> call at the beginning of the function.
>>>>>>
>>>>>> This is an essential requirement for the discussed source code search pattern,
>>>>>> isn't it?
>>>>>
>>>>> No.
>>>>
>>>> I hope still that a better common understanding can be achieved.
>>>>
>>>>
>>>>>      I don't understand why you think that.
>>>>
>>>> The source code search pattern tries to find a pair of lock calls.
>>>> Is the passed expression determined for the metavariable “y” after the second
>>>> lock call was found at the beginning of the function implementation?
>>>
>>> I don't understand this at all.
>>
>> Does this feedback indicate another communication problem?
>>
>>
>>>                                  Coccinelle doesn't care about the
>>> beginning of the function, unless you start the pattern with a function
>>> header or a ...
>>
>> Where does the statement “action_lock(&blockage1);” appear in the implementation
>> of the function “my_action_test”?
> 
> It is at the beginning of the function.

Thanks for another bit of positive feedback.


>                                          But that the fact that x matches
> &blockage1 n one place doesn't mean that it can't match something else
> when checking for a match at another place in the code.

This technical aspect can be usable for further source code search approaches.


>                                                          If you hava a
> function like
> 
> int f() {
>   a(1);
>   a(2);
>   a(3);
> }
> 
> and your semantic patch is:
> 
> @@
> expression x;
> @@
> 
> * a(x);
> 
> Then all calls to a will be marked, because the pattern can march in three
> different places, with three different bindings of x.

It seems that this software behaviour (according to the functionality “semantic match”)
was not officially documented so far.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/3aa9a6ab3b035e31292be31399b99a8857480aef/docs/manual/cocci_syntax.tex#L1214-1225

Would it be cleaner to use the SmPL construct “<+... … ...+>” accordingly?


>> Would it be possible to determine that special control flow from an if branch
>> would be inappropriate according to the mentioned SmPL code?
> 
> If you don't want a match to go over an if,

There are further constraints to consider.


>                                             you have to add the if to the
> pattern to specify that.

I do not like this suggestion.

It should be possible in a simpler way to point source code places out
which start with a selected function call combination.

Regards,
Markus

  reply	other threads:[~2025-08-02 18:12 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
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 [this message]
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=a86ce687-61a5-4e52-92fa-6a0d53db9360@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.