linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open()
@ 2012-03-13 16:58 Julia Lawall
  2012-03-26 20:44 ` Michal Marek
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2012-03-13 16:58 UTC (permalink / raw)
  To: sboyd
  Cc: kernel-janitors, gregkh, viro, akpm, linux-kernel, linux-fsdevel, mmarek

From: Julia Lawall <Julia.Lawall@lip6.fr>

Find instances of an open-coded simple_open() and replace them
with calls to simple_open().

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reported-by: Stephen Boyd <sboyd@codeaurora.org>

---
 scripts/coccinelle/api/simple_open.cocci |   70 +++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci
new file mode 100644
index 0000000..05962f7
--- /dev/null
+++ b/scripts/coccinelle/api/simple_open.cocci
@@ -0,0 +1,70 @@
+/// This removes an open coded simple_open() function
+/// and replaces file operations references to the function
+/// with simple_open() instead.
+///
+// Confidence: High
+// Comments:
+// Options: -no_includes -include_headers
+
+virtual patch
+virtual report
+
+@ open depends on patch @
+identifier open_f != simple_open;
+identifier i, f;
+@@
+-int open_f(struct inode *i, struct file *f)
+-{
+(
+-if (i->i_private)
+-f->private_data = i->i_private;
+|
+-f->private_data = i->i_private;
+)
+-return 0;
+-}
+
+@ has_open depends on open @
+identifier fops;
+identifier open.open_f;
+@@
+struct file_operations fops = {
+...,
+-.open = open_f,
++.open = simple_open,
+...
+};
+
+@ openr depends on report @
+identifier open_f != simple_open;
+identifier i, f;
+position p;
+@@
+int open_f@p(struct inode *i, struct file *f)
+{
+(
+if (i->i_private)
+f->private_data = i->i_private;
+|
+f->private_data = i->i_private;
+)
+return 0;
+}
+
+@ has_openr depends on openr @
+identifier fops;
+identifier openr.open_f;
+position p;
+@@
+struct file_operations fops = {
+...,
+.open = open_f@p,
+...
+};
+
+@script:python@
+pf << openr.p;
+ps << has_openr.p;
+@@
+
+coccilib.report.print_report(pf[0],"WARNING opportunity for simple_open, see also structure on line %s"%(ps[0].line))


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

* Re: [PATCH] scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open()
  2012-03-13 16:58 [PATCH] scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open() Julia Lawall
@ 2012-03-26 20:44 ` Michal Marek
  2012-03-26 20:48   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Marek @ 2012-03-26 20:44 UTC (permalink / raw)
  To: Julia Lawall
  Cc: sboyd, kernel-janitors, gregkh, viro, akpm, linux-kernel, linux-fsdevel

On Tue, Mar 13, 2012 at 05:58:37PM +0100, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Find instances of an open-coded simple_open() and replace them
> with calls to simple_open().
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> Reported-by: Stephen Boyd <sboyd@codeaurora.org>

Thanks, applied to kbuild.git#misc now.

Michal

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

* Re: [PATCH] scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open()
  2012-03-26 20:44 ` Michal Marek
@ 2012-03-26 20:48   ` Andrew Morton
  2012-03-26 20:51     ` Michal Marek
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2012-03-26 20:48 UTC (permalink / raw)
  To: Michal Marek
  Cc: Julia Lawall, sboyd, kernel-janitors, gregkh, viro, linux-kernel,
	linux-fsdevel

On Mon, 26 Mar 2012 22:44:07 +0200
Michal Marek <mmarek@suse.cz> wrote:

> On Tue, Mar 13, 2012 at 05:58:37PM +0100, Julia Lawall wrote:
> > From: Julia Lawall <Julia.Lawall@lip6.fr>
> > 
> > Find instances of an open-coded simple_open() and replace them
> > with calls to simple_open().
> > 
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> > Reported-by: Stephen Boyd <sboyd@codeaurora.org>
> 
> Thanks, applied to kbuild.git#misc now.
> 

That's a bit premature, as simple_open() isn't upstream yet.



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

* Re: [PATCH] scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open()
  2012-03-26 20:48   ` Andrew Morton
@ 2012-03-26 20:51     ` Michal Marek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Marek @ 2012-03-26 20:51 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Julia Lawall, sboyd, kernel-janitors, gregkh, viro, linux-kernel,
	linux-fsdevel

Dne 26.3.2012 22:48, Andrew Morton napsal(a):
> On Mon, 26 Mar 2012 22:44:07 +0200
> Michal Marek <mmarek@suse.cz> wrote:
> 
>> On Tue, Mar 13, 2012 at 05:58:37PM +0100, Julia Lawall wrote:
>>> From: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> Find instances of an open-coded simple_open() and replace them
>>> with calls to simple_open().
>>>
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>> Reported-by: Stephen Boyd <sboyd@codeaurora.org>
>>
>> Thanks, applied to kbuild.git#misc now.
>>
> 
> That's a bit premature, as simple_open() isn't upstream yet.

Oops, sorry. I haven't pushed the branch yet, so I will remove the patch
again.

Michal

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

end of thread, other threads:[~2012-03-26 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 16:58 [PATCH] scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open() Julia Lawall
2012-03-26 20:44 ` Michal Marek
2012-03-26 20:48   ` Andrew Morton
2012-03-26 20:51     ` Michal Marek

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).