From: Julia Lawall <julia.lawall@lip6.fr>
To: Joe Perches <joe@perches.com>
Cc: cocci <cocci@systeme.lip6.fr>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Cocci] cocci: remove unnecessary casts of void * while avoiding casts with __user or __force ?
Date: Tue, 29 Aug 2017 07:17:58 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1708290700520.2035@hadrien> (raw)
In-Reply-To: <1503938959.2040.6.camel@perches.com>
On Mon, 28 Aug 2017, Joe Perches wrote:
> A simple cocci script that removes unnecessary casts of
> a void * will also remove casts with __force or __user
Unfortunately, attributes are currently not supported inside casts. This
can be done in a hackish way (possible false negatives) as follows:
---
@initialize:ocaml@
@@
let close (p1,p2) =
let r = (List.hd p1).line_end in
let l = (List.hd p2).line in
let rc = (List.hd p1).col_end in
let lc = (List.hd p2).col in
r = l && lc = rc+1
@r@
position p1,p2;
expression f,e;
type T;
@@
f(..., // generalize this rule as needed
(T@p1 *@p2)
e,...)
@@
position r.p2 : script:ocaml(r.p1) { close(p1,p2) };
position r.p1;
expression e;
type T;
@@
- (T@p1 *@p2)
e
---
Basically, it assumes that if the type and the * are more than one space
apart then there is something important there, and the cast is not
removed.
julia
prev parent reply other threads:[~2017-08-29 5:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 16:49 Joe Perches
2017-08-29 5:17 ` Julia Lawall [this message]
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=alpine.DEB.2.20.1708290700520.2035@hadrien \
--to=julia.lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/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®