cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Timur Tabi <timur@kernel.org>
To: cocci <cocci@systeme.lip6.fr>
Subject: [Cocci] Can I pass a variable from a Python script in one rule to another rule in the same .cocci file?
Date: Fri, 4 Jan 2019 15:57:25 -0600	[thread overview]
Message-ID: <CAOZdJXWUhEcm8HgJFE2L1dqgMRX51X+LF=b=Obzj55pU4gc3QA@mail.gmail.com> (raw)

In one rule, I have some Python code that parses a string literal to
see what it looks like.  If I detect a specific pattern, then I want
another rule (that has no Python code) to act differently.

More specifically, if a string literal passed as a parameter to
DBG_PRINTF() starts with "NVRM: ", then I want my script to replace
DBG_PRINTF with NV_PRINTF.  This works today.

If the string does not begin with "NVRM:", however, then I want
DBG_PRINTF changed to NV_PRINTF_EX instead.

If this can't work, an alternative would be to create a second script
that handles DBG_PRINTF to NV_PRINTF_EX.  However, it would need to
abort the change if the Python script detects that NVRM: doesn't
exist.  So is there a way for Python to return a value that says,
"Woah, stop and undo everything you just did!"
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

             reply	other threads:[~2019-01-04 21:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 21:57 Timur Tabi [this message]
2019-01-05  6:25 ` [Cocci] Can I pass a variable from a Python script in one rule to another rule in the same .cocci file? 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='CAOZdJXWUhEcm8HgJFE2L1dqgMRX51X+LF=b=Obzj55pU4gc3QA@mail.gmail.com' \
    --to=timur@kernel.org \
    --cc=cocci@systeme.lip6.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 NNTP newsgroup(s).