Coccinelle Archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Matching attributes
@ 2021-01-08 23:48 Lukas Straub
  2021-01-09  7:34 ` Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Straub @ 2021-01-08 23:48 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 729 bytes --]

Hello Everyone,
I am toying with coccinelle to assist in writing c code. My first try is to
automatically free/cleanup local variables when they go out of scope.

This works very well already:

 @@
 type T;
 identifier var;
 attribute name autofree;
 @@
 
    T var
 -  autofree
    = NULL;
    ...
 ++ free(var);
    return ...;

But this fails:

 @@
 type T;
 identifier var;
 attribute name autofree;
 @@
 
    T var autofree;
    ...
 ++ free(var);
    return ...;

with

 minus: parse error: 
   File "autofree.cocci", line 7, column 17, charpos = 73
   around = ';',
   whole content =    T var autofree;

What am I doing wrong here?
I tried both with v1.0.8 and latest git.
-- 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Matching attributes
  2021-01-08 23:48 [Cocci] Matching attributes Lukas Straub
@ 2021-01-09  7:34 ` Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2021-01-09  7:34 UTC (permalink / raw)
  To: Lukas Straub; +Cc: cocci

> But this fails:
>
>  @@
>  type T;
>  identifier var;
>  attribute name autofree;
>  @@
>
>     T var autofree;
>     ...
>  ++ free(var);
>     return ...;
>
> with
>
>  minus: parse error:
>    File "autofree.cocci", line 7, column 17, charpos = 73
>    around = ';',
>    whole content =    T var autofree;
>
> What am I doing wrong here?
> I tried both with v1.0.8 and latest git.

Thanks for the report.  I will look into it.

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

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 23:48 [Cocci] Matching attributes Lukas Straub
2021-01-09  7:34 ` Julia Lawall

Coccinelle Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git