All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Edworthy <phil.edworthy@renesas.com>
To: "cocci@inria.fr" <cocci@inria.fr>
Subject: [cocci] Matching an if statement with just one func call
Date: Mon, 16 May 2022 18:34:09 +0000	[thread overview]
Message-ID: <TYYPR01MB7086CFE025C9A65F40613D61F5CF9@TYYPR01MB7086.jpnprd01.prod.outlook.com> (raw)

Hi,

I'm trying to get my coccinelle test to detect code in
the Linux kernel similar to:
if (!clk)
   clk_disable_unprepare(clk);

So far, I have got:
expression clk;
position p1,p2;
@@

if@p1 ( \( !clk \| clk != NULL \| !IS_ERR(clk) \) )
{ ...
clk_disable_unprepare@p2(clk)
}

However, I don't want to pick up code where something else is covered
by the if statement, such as:
if (!clk) {
   do_something_else;
   clk_disable_unprepare(clk);
}

I know it's related to the ... but I can't get it to work.
Sorry, I'm a coccinelle newbie.

Any help appreciated!

Thanks
Phil

             reply	other threads:[~2022-05-16 20:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16 18:34 Phil Edworthy [this message]
2022-05-16 20:21 ` [cocci] Matching an if statement with just one func call Julia Lawall
2022-05-17  6:45   ` Phil Edworthy

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=TYYPR01MB7086CFE025C9A65F40613D61F5CF9@TYYPR01MB7086.jpnprd01.prod.outlook.com \
    --to=phil.edworthy@renesas.com \
    --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 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.