On Mon, 6 Jun 2011, Joe Perches wrote:
> Given source input:
>
> $ cat t.c
> #include <linux/kernel.h>
> #include <linux/ioport.h>
>
> struct resource array[] = {
> {.start = 0x11111, .end=0x22222},
> {.start = 0x33333, .end=0x44444},
> {.start = 0x55555, .end=0x66666},
> };
> struct resource *p = array;
>
> void test_resource(void)
> {
> int i;
> for (i = 0; i < ARRAY_SIZE(array); i++)
> if (p[i].end - p[i].start + 1 > 0x12345)
> printk(KERN_CRIT "Some failure\n");
> }
> $
>
> and spatch input:
>
> $ cat resource.cocci
> @@
> struct resource *ptr;
> @@
>
> - ptr->end - ptr->start + 1
> + resource_size(ptr)
> $
>
> and
>
> $ spatch -version
> spatch version 1.0.0-rc3 with Python support
> $
>
> spatch incorrrectly produces:
>
> $ spatch -very_quiet -sp_file resource.cocci t.c
> --- t.c 2011-06-06 18:09:58.948214792 -0700
> +++ /tmp/cocci-output-27700-056d06-t.c 2011-06-06 18:13:25.324214761
> -0700
> @@ -13,6 +13,6 @@ void test_resource(void)
> {
> int i;
> for (i = 0; i < ARRAY_SIZE(array); i++)
> - if (p[i].end - p[i].start + 1 > 0x12345)
> + if (resource_size(p) > 0x12345)
> printk(KERN_CRIT "Some failure\n");
> }
> $
>
> I believe transform should be to:
>
> + if (resource_size(&p[i]) > 0x12345)
Thanks. It looks like an isomorphism gone awry. Unfotunately, I suspect
that the solution will involve it just not matching this case. So you
would have to take it into account explicitly.
I'll look into it.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)