-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 298652 b: refs/heads/master c: 9b3ae64 h: refs/heads/master v: v3
- Loading branch information
Julia Lawall
authored and
Linus Torvalds
committed
Apr 5, 2012
1 parent
ef83969
commit d7c74e4
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 20955e891d828b2027281fe3295dae6af8e0423b | ||
refs/heads/master: 9b3ae64be658a573b33d05a8dc73b08d3345fa44 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |