Re: [Cocci] expression without side effects

2020-09-02 Thread Julia Lawall



On Wed, 2 Sep 2020, Denis Efremov wrote:

>
>
> On 9/2/20 3:32 PM, Julia Lawall wrote:
> > There is an isomorphism that you can disable: ptr_to_array
>
> Thanks!
>
> Anyway, even with ptr_to_array enabled equalizing cmd->dmap[0] and
> cmd->dmap[1] looks incorrect to me.

Indeed, in looking at the rule, it doesn't look like this is the kind of
expression that should be involved...

julia
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] expression without side effects

2020-09-02 Thread Denis Efremov



On 9/2/20 3:32 PM, Julia Lawall wrote:
> There is an isomorphism that you can disable: ptr_to_array

Thanks!

Anyway, even with ptr_to_array enabled equalizing cmd->dmap[0] and
cmd->dmap[1] looks incorrect to me.


Denis
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] expression without side effects

2020-09-02 Thread Julia Lawall



On Wed, 2 Sep 2020, Denis Efremov wrote:

> Hi,
>
> I'm trying to write a pattern to match expression without side-effects,
> i.e expression E but not i++, --i, function call.
>
> While trying to write it I faced that this expression matches different
> array indices. Actually, it's quite unexpected for me:
>
> @@
> expression E;
> identifier A;
> @@
>
> * E->A || E->A

There is an isomorphism that you can disable: ptr_to_array

julia

>
> Actually, I would expect it not to match the file at all:
>
> $ spatch --cocci-file ./test.cocci ./drivers/md/dm-clone-metadata.c
> init_defs_builtins: /usr/lib64/coccinelle/standard.h
> HANDLING: ./drivers/md/dm-clone-metadata.c
> diff =
> --- ./drivers/md/dm-clone-metadata.c
> +++ /tmp/cocci-output-11041-66b4fb-dm-clone-metadata.c
> @@ -947,7 +947,6 @@ bool dm_clone_changed_this_transaction(s
> unsigned long flags;
>
> spin_lock_irqsave(>bitmap_lock, flags);
> -   r = cmd->dmap[0].changed || cmd->dmap[1].changed;
> spin_unlock_irqrestore(>bitmap_lock, flags);
>
> return r;
>
> Thanks,
> Denis
> ___
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


[Cocci] expression without side effects

2020-09-02 Thread Denis Efremov
Hi,

I'm trying to write a pattern to match expression without side-effects, 
i.e expression E but not i++, --i, function call.

While trying to write it I faced that this expression matches different
array indices. Actually, it's quite unexpected for me:

@@
expression E;
identifier A;
@@

* E->A || E->A

Actually, I would expect it not to match the file at all:

$ spatch --cocci-file ./test.cocci ./drivers/md/dm-clone-metadata.c
init_defs_builtins: /usr/lib64/coccinelle/standard.h
HANDLING: ./drivers/md/dm-clone-metadata.c
diff =
--- ./drivers/md/dm-clone-metadata.c
+++ /tmp/cocci-output-11041-66b4fb-dm-clone-metadata.c
@@ -947,7 +947,6 @@ bool dm_clone_changed_this_transaction(s
unsigned long flags;

spin_lock_irqsave(>bitmap_lock, flags);
-   r = cmd->dmap[0].changed || cmd->dmap[1].changed;
spin_unlock_irqrestore(>bitmap_lock, flags);

return r;

Thanks,
Denis
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci