cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [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

* Re: [Cocci] expression without side effects
  2020-09-02 12:32 ` Julia Lawall
@ 2020-09-02 13:00   ` Denis Efremov
  2020-09-02 13:14     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Efremov @ 2020-09-02 13:00 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Cocci] expression without side effects
  2020-09-02 13:00   ` Denis Efremov
@ 2020-09-02 13:14     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2020-09-02 13:14 UTC (permalink / raw)
  To: Denis Efremov; +Cc: Coccinelle



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

^ 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).