qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Coccinelle semantic patches (was Re: [PATCH 1/9] error: New


From: Eduardo Habkost
Subject: [Qemu-devel] Coccinelle semantic patches (was Re: [PATCH 1/9] error: New convenience function error_report_err())
Date: Wed, 11 Feb 2015 11:13:46 -0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Wed, Feb 11, 2015 at 11:17:40AM +0100, Paolo Bonzini wrote:
> 
> 
> On 10/02/2015 23:04, Eduardo Habkost wrote:
> > $ spatch --sp-file /tmp/error_report.spatch $(git grep -l error_report) > 
> > /tmp/error_report.patch
> 
> Does it work without specifying any include path?

I didn't even know it had include path options. I don't know what it would use
it for (I guess there are some use cases where parsing the include files would
be useful, but I am not aware of them).

> 
> I tried this a while ago:
> 
> @@
> identifier s, fld;
> @@
>   struct s {
>     ...
> -   QEMUTimer *fld;
> +   QEMUTimer fld;
>     ...
>   }
> @@
> expression E;
> identifier fld;
> @@
> - E->fld = timer_new_ms(
> + timer_init_ms(&E->fld,
>     ...
>   );
> 
> 
> (The patch is incomplete, but shows the problem).  "spatch --sp-file
> timer.cocci hw/arm/pxa2xx.c" misses the first replacement for struct
> PXA2xxRTCState, but "spatch --sp-file timer.cocci hmp.c" does it right
> in struct MigrationStatus.

That's because your rule doesn't match the PXA2xxRTCState declaration, that is
written as "typedef struct { ... } PXA2xxRTCState", and hence doesn't match the
"struct s { ... }" pattern.

I don't know how to write a rule that matches both (the "\( a \| b \)"
format seems to work only inside statement lists). As a good
plier-wielding ogre, I would give up and simply write two rules:

@@
identifier fld;
@@
 struct {
    ...
-   QEMUTimer *fld;
+   QEMUTimer fld;
    ...
 }

@@
identifier s, fld;
@@
 struct s {
    ...
-   QEMUTimer *fld;
+   QEMUTimer fld;
    ...
 }
@@
expression E;
identifier fld;
@@
- E->fld = timer_new_ms(
+ timer_init_ms(&E->fld,
    ...
  );


-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]