[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
- [Qemu-devel] [PATCH 0/9] Clean up around error_get_pretty(), qerror_report_err(), Markus Armbruster, 2015/02/10
- [Qemu-devel] [PATCH 3/9] monitor: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
- [Qemu-devel] [PATCH 6/9] tpm: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
- [Qemu-devel] [PATCH 2/9] monitor: Clean up around monitor_handle_fd_param(), Markus Armbruster, 2015/02/10
- [Qemu-devel] [PATCH 1/9] error: New convenience function error_report_err(), Markus Armbruster, 2015/02/10
- Re: [Qemu-devel] [PATCH 1/9] error: New convenience function error_report_err(), Markus Armbruster, 2015/02/11
- Re: [Qemu-devel] [PATCH 1/9] error: New convenience function error_report_err(), Eric Blake, 2015/02/10
[Qemu-devel] [PATCH 7/9] vl: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
[Qemu-devel] [PATCH 5/9] numa: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
[Qemu-devel] [PATCH 9/9] qemu-char: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
[Qemu-devel] [PATCH 8/9] qemu-img: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
[Qemu-devel] [PATCH 4/9] net: Avoid qerror_report_err() outside QMP command handlers, Markus Armbruster, 2015/02/10
Re: [Qemu-devel] [PATCH 0/9] Clean up around error_get_pretty(), qerror_report_err(), Eric Blake, 2015/02/11