Re: [PATCH] base firmware: Fix BUG from sysfs attributes change incommit a2db6842873c8e5a70652f278d469128cb52db70
From: Wolfram Sang
Date: Sun Mar 14 2010 - 20:49:29 EST
On Sun, Mar 14, 2010 at 12:08:55PM -0700, Eric W. Biederman wrote:
> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:
>
> > On Sun, 14 Mar 2010, Wolfram Sang wrote:
> >>
> >> coccinelle can apply semantic patches, rough description here [1]. So I wrote
> >> one which checks for every c-file in the kernel-tree:
> >>
> >> - Is there a structure containing (bin_)attribute?
> >> - Does a function declare a pointer to such a structure?
> >> - Is this pointer then used for a sysfs_create(_bin)_file?
> >> - If so, has there been a call to sysfs(_bin)_attr_init before?
> >>
> >> If not -> report. As coccinelle works on an abstract level of the code (not on
> >> source-code level), it can follow code-paths and such. Really nice tool, once
> >> you gathered the information to learn it.
>
> Any chance you can post the semantic patch? If it isn't too hard it
> would be nice to have the warm fuzzy of running it myself and seeing
> that there are no more of these left in the kernel.
(Strange, I sent an introductory message to the series:
http://kerneltrap.org/mailarchive/linux-kernel-janitors/2010/3/12/6848563
But it doesn't show up in the gmane-archives? And I just learned that CCs added
while editing the introductory message will be dropped by git-send-email. This
is why it isn't on lkml. I have to fix that next time.)
Sure, reviewing is very welcome. I am still new to the semantic patches, so a
double check is surely helpful (also adding Julia Lawall to cc, grand master of
this topic).
Here is the patch again for the binary-attributes (I recommend coccinelle
v0.2.2. Run it with 'spatch -sp_file <name> .' form kernel-top-level-dir):
@ init @
identifier struct_name, bin;
@@
struct struct_name {
...
struct bin_attribute bin;
...
};
@ main extends init @
expression E;
statement S;
identifier name, err;
@@
(
struct struct_name *name;
|
- struct struct_name *name = NULL;
+ struct struct_name *name;
)
...
(
sysfs_bin_attr_init(&name->bin);
|
+ sysfs_bin_attr_init(&name->bin);
if (sysfs_create_bin_file(E, &name->bin))
S
|
+ sysfs_bin_attr_init(&name->bin);
err = sysfs_create_bin_file(E, &name->bin);
)
Here is my patch for the non-binary-attributes:
@ init @
identifier struct_name, attr;
@@
struct struct_name {
...
struct attribute attr;
...
};
@ main extends init @
expression E;
statement S;
identifier name, err;
@@
(
struct struct_name *name;
|
- struct struct_name *name = NULL;
+ struct struct_name *name;
)
...
(
sysfs_attr_init(&name->attr);
|
+ sysfs_attr_init(&name->attr);
if (sysfs_create_file(E, &name->attr))
S
|
+ sysfs_attr_init(&name->attr);
err = sysfs_create_file(E, &name->attr);
)
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Attachment:
signature.asc
Description: Digital signature