public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] convert comma to semicolon
@ 2013-08-10 15:40 Julia Lawall
  2013-08-10 15:40 ` [PATCH 1/5] drivers/gpio/gpio-omap.c: " Julia Lawall
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Julia Lawall @ 2013-08-10 15:40 UTC (permalink / raw)
  To: linux-kernel, trivial; +Cc: kernel-janitors

These patches result from the following semantic patches
(http://coccinelle.lip6.fr/), which check for expression statements
separated by , rather than by ;.  The first semantic patch is quite
conservative in that it only finds cases where this pattern appears after
another complete statement or at the beginning of a block, to ensure that
the expression statements do not form eg an if branch or loop body.
Iteration is used to treat arbitrary sequences of commas.  The second
semantic patch treats any kind of comma, and is intended to be used on code
to which the first one has already been applied.  This one adjusts commas
in if branches, following preprocessor directves, etc.  The results of the
second semantic patch often need some hand cleaning, to insert tabs, put
braces on the right lines, etc.

The first semantic patch (very safe):

// <smpl>
@initialize:ocaml@

let tbl = Hashtbl.create(100)

let add_if_not_present file =
try let _ = Hashtbl.find tbl file in ()
with Not_found ->
   Hashtbl.add tbl file ();
   let it = new iteration() in
   it#set_files [file];
   it#register()

@script:ocaml@
@@
Hashtbl.clear tbl

@r@
statement S1,S2;
expression e1,e2,e;
position p1,p2;
type T;
identifier i;
iterator I;
@@

(
if (...) S1 else S2
|
while (...) S1
|
for (...;...;...) S1
|
I (...) S1
|
T i;
|
 e;
)
 e1,@p1 e2@p2;

@script:ocaml@
p1 << r.p1;
p2 << r.p2;
@@

if (List.hd p1).line = (List.hd p2).line
then include_match false
else add_if_not_present ((List.hd p1).file)

@@
expression e1,e2;
position r.p1;
@@

 e1
- ,@p1
+ ;
  e2;

@s disable braces3@
identifier f;
expression e1,e2;
position p1,p2;
@@

{
 e1,@p1 e2@p2;
 ... when any
}

@script:ocaml@
p1 << s.p1;
p2 << s.p2;
@@

if (List.hd p1).line = (List.hd p2).line
then include_match false
else add_if_not_present ((List.hd p1).file)

@@
expression e1,e2;
position s.p1;
@@

 e1
- ,@p1
+ ;
  e2;
// </smpl>

The second semantic patch (less safe, results require some cleanup):

// <smpl>
@initialize:ocaml@

let tbl = Hashtbl.create(100)

let add_if_not_present file =
try let _ = Hashtbl.find tbl file in ()
with Not_found ->
   Hashtbl.add tbl file ();
   let it = new iteration() in
   it#set_files [file];
   it#register()

@script:ocaml@
@@
Hashtbl.clear tbl

@r@
expression e1,e2;
position p1,p2;
@@

 e1,@p1 e2@p2;

@script:ocaml@
p1 << r.p1;
p2 << r.p2;
@@

if (List.hd p1).line = (List.hd p2).line
then include_match false
else add_if_not_present ((List.hd p1).file)

@@
expression e1,e2;
position r.p1;
@@

 e1
- ,@p1
+ ;
  e2;

// </smpl>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-08-16 15:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-10 15:40 [PATCH 0/5] convert comma to semicolon Julia Lawall
2013-08-10 15:40 ` [PATCH 1/5] drivers/gpio/gpio-omap.c: " Julia Lawall
2013-08-10 16:13   ` Joe Perches
2013-08-12 16:15     ` Kevin Hilman
2013-08-16 15:13       ` Linus Walleij
2013-08-10 15:40 ` [PATCH 2/5] crypto/camellia_generic.c: " Julia Lawall
2013-08-10 16:19   ` Joe Perches
2013-08-10 16:25     ` Julia Lawall
2013-08-10 15:40 ` [PATCH 3/5] arch/x86/crypto/camellia_glue.c: " Julia Lawall
2013-08-10 15:40 ` [PATCH 4/5] trivial: " Julia Lawall
2013-08-10 15:40 ` [PATCH 5/5] " Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox