Németh Márton wrote:
> Julia Lawall wrote:
>> My thought was to find a field that is declared as const, then find a
>> static initialization of that field, and then convert the initialized
>> value to const. So it would be something like:
>>
> [snip]
>> You would of course have to check that const is not already there as you
>> have done in your previous rule.
>>
>> I have not tested this at all.
>
> Here is the working version based on your one. This one can find the
> control descriptor the same like the original SmPL did. The "-all_includes"
> option has to be used.
>
> [snip]
I run the SmPL against the Linux kernel 2.6.32-rc2. In some cases there is
the __devinitdata is also specified. When adding "const" the __devinitdata has
to be also changed to __devinitconst. I tried like this, but something is needed
to tell spatch about "__devinitdata":
// <smpl>
@r@
identifier I1, I2, x;
@@
struct I1 {
...
const struct I2 *x;
...
};
@s@
identifier r.I1, y;
identifier r.x, E;
@@
struct I1 y = {
.x = E,
};
@c@
identifier r.I2;
identifier s.E;
@@
const struct I2 E[] = ... ;
@i depends on !c@
identifier r.I2;
identifier s.E;
@@
+ const
struct I2
- __devinitdata
+ __devinitconst
E[] = ...;
@depends on !c && !i@
identifier r.I2;
identifier s.E;
@@
+ const
struct I2 E[] = ...;
// </smpl>
Here is the test c file:
---8<---- cut here ---8<---
struct A {
int aa;
const int ab;
int ac;
};
struct B {
int ba;
const int bb;
};
struct C {
const struct A *pa;
struct B *pb;
};
struct A __devinitdata x[] = {
{
0,
1,
2
}
};
struct B __devinitdata z[] = {
{
7,
8,
}
};
struct C __devinitdata q = {
.pa = x,
.pb = z,
};
---8<---- cut here ---8<---
The expected patch would be:
--- test4.c 2010-01-04 06:54:51.000000000 +0100
+++ /tmp/cocci-output-6242-194b66-test4.c 2010-01-04 07:11:11.000000000
+0100
@@ -15,7 +15,7 @@ struct C {
struct B *pb;
};
-struct A __devinitdata x[] = {
+const struct A __devinitconst x[] = {
{
0,
1,
How can I express the "__devinitdata" in SmPL?
Regards,
Márton Németh
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)