* [Cocci] expression without side effects
@ 2020-09-02 12:27 Denis Efremov
2020-09-02 12:32 ` Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Denis Efremov @ 2020-09-02 12:27 UTC (permalink / raw)
To: Coccinelle
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(&cmd->bitmap_lock, flags);
- r = cmd->dmap[0].changed || cmd->dmap[1].changed;
spin_unlock_irqrestore(&cmd->bitmap_lock, flags);
return r;
Thanks,
Denis
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Cocci] expression without side effects
2020-09-02 12:27 [Cocci] expression without side effects Denis Efremov
@ 2020-09-02 12:32 ` Julia Lawall
2020-09-02 13:00 ` Denis Efremov
0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2020-09-02 12:32 UTC (permalink / raw)
To: Denis Efremov; +Cc: Coccinelle
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(&cmd->bitmap_lock, flags);
> - r = cmd->dmap[0].changed || cmd->dmap[1].changed;
> spin_unlock_irqrestore(&cmd->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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-02 13:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-02 12:27 [Cocci] expression without side effects Denis Efremov
2020-09-02 12:32 ` Julia Lawall
2020-09-02 13:00 ` Denis Efremov
2020-09-02 13:14 ` Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.