From: Joel Fernandes <joel@joelfernandes.org>
To: linux-kernel@vger.kernel.org, Julia Lawall <Julia.Lawall@lip6.fr>,
Gilles Muller <Gilles.Muller@lip6.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
Michal Marek <michal.lkml@markovi.net>,
cocci@systeme.lip6.fr, Kees Cook <keescook@chromium.org>
Subject: First coccinelle script, need some help.
Date: Wed, 10 Oct 2018 12:38:54 -0700 [thread overview]
Message-ID: <20181010193854.GA93016@joelaf.mtv.corp.google.com> (raw)
Hi!
I am trying to determine if a function argument is used across the whole
kernel for a certain kernel function.
I mustered up enough courage to write my first coccinelle script after a few
late nights of reading up about it :)
Here is .cocci script. I am trying to find if address is used at all in any
possible definitions of pte_alloc():
$ cat ~/pte_alloc.cocci
virtual report
@pte_args depends on report@
identifier E1, E2;
type T1, T2;
position p;
@@
pte_alloc@p(T1 E1, T2 E2)
{
...
(
...
E2
...
)
...
}
@script:python depends on report@
p << pte_args.p;
@@
coccilib.report.print_report(p[0], "WARNING: found definition of
apte_alloc_one with address used in the body")
The above warning does fire on the following test.c program:
struct page *pte_alloc(struct mm_struct *mm, unsigned long address)
{
address++;
if (condition()) {
return NULL;
}
}
But, *not* if I move 'address' into the if block:
struct page *pte_alloc(struct mm_struct *mm, unsigned long address)
{
if (condition()) {
address++;
return NULL;
}
}
I could not understand why, In my view the "address" expression should be
matched across the function body even within if blocks. But if I move
"address" into the if block, then the match doesn't occur any longer.
My coccicheck command is as follow:
make coccicheck COCCI=~/pte_alloc.cocci MODE=report M=test/test.c
What am I missing? Thanks for any help.
thanks,
- Joel
next reply other threads:[~2018-10-10 19:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 19:38 Joel Fernandes [this message]
2018-10-10 20:23 ` Julia Lawall
2018-10-10 20:45 ` Joel Fernandes
2018-10-10 20:51 ` Julia Lawall
2018-10-10 21:11 ` Joel Fernandes
2018-10-10 21:12 ` 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=20181010193854.GA93016@joelaf.mtv.corp.google.com \
--to=joel@joelfernandes.org \
--cc=Gilles.Muller@lip6.fr \
--cc=Julia.Lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=nicolas.palix@imag.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
all inboxes | Powered by JetHome®