Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Subject: [cocci] Checking the search for a repeated condition check with SmPL
Date: Fri, 9 Feb 2024 16:40:33 +0100	[thread overview]
Message-ID: <c5bcc0b5-1a19-4256-8572-b9ee5e78ea0f@web.de> (raw)

Hello,

I noticed another contribution by Dan Carpenter.
[PATCH] dm vdo slab-depot: delete unnecessary check
https://lore.kernel.org/lkml/16ffd614-48a9-42b8-961d-2dc8a69c48d6@moroto.mountain/
https://lkml.org/lkml/2024/2/9/397


I constructed another SmPL script variant accordingly.


@deletion@
binary operator bo;
constant c;
expression e;
identifier var;
@@
 if (
(    var bo c
&    e
)
 )
    return var;
 ... when != var
-if (e)
-   return var;


The known patch is generated then as expected for a source file
according to the software “Linux next-20240209”.

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> spatch …/Projekte/Coccinelle/janitor/delete_redundant_if_statement.cocci drivers/md/dm-vdo/slab-depot.c
…
@@ -4100,9 +4100,6 @@ static int allocate_components(struct sl
                };
        }

-       if (result != VDO_SUCCESS)
-               return result;
-
        slab_count = vdo_compute_slab_count(depot->first_block, depot->last_block,
                                            depot->slab_size_shift);
        if (thread_config->physical_zone_count > slab_count) {



I tried also the following SmPL script variant out together with
the software combination “Coccinelle 1.1.1-00676-g99513ec1”.


@deletion2@
binary operator bo;
constant c;
expression e;
identifier var;
@@
 if (var bo c)
    return var;
 ... when != var
-if (var bo c)
-   return var;


I wonder then why no patch is generated by the corresponding test.

Regards,
Markus

             reply	other threads:[~2024-02-09 15:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 15:40 Markus Elfring [this message]
2024-02-11  8:24 ` [cocci] Checking the search for a repeated condition check with SmPL Markus Elfring
2024-02-11  8:42   ` Julia Lawall
2024-02-11  9:55     ` Markus Elfring
2024-02-11 10:29       ` Julia Lawall
2024-02-15  8:18   ` Markus Elfring
2024-02-15  9:29     ` Julia Lawall
2024-02-15 10:33       ` Markus Elfring
2024-02-18  8:03         ` Markus Elfring
2024-02-18  8:11           ` Julia Lawall
2024-02-18  8:55             ` Markus Elfring
2024-02-18 16:12               ` Julia Lawall
2024-02-18 17:30                 ` Markus Elfring
2024-02-19  7:30                 ` Markus Elfring
2024-02-19  7:36                   ` Julia Lawall
2024-02-19  7:48                     ` Markus Elfring
2024-02-19  9:45                 ` Markus Elfring
2024-02-17 13:14 ` [cocci] Fixing the SmPL search for a bit of duplicate code Markus Elfring
2024-02-17 15:23   ` Julia Lawall
2024-02-17 16:38     ` Markus Elfring
2024-02-18  7:04       ` Markus Elfring
2024-02-18  7:44         ` Julia Lawall
2024-02-18 19:33       ` Markus Elfring
2024-02-18 19:43         ` Julia Lawall

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=c5bcc0b5-1a19-4256-8572-b9ee5e78ea0f@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).