[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp
- To: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Eric Blake <eblake@xxxxxxxxxx>
- Date: Mon, 23 Sep 2019 15:05:49 -0500
- Autocrypt: addr=eblake@xxxxxxxxxx; keydata= xsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU xphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD TUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV GmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP sAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB AAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV CgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX RjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz wTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+KbpADsc7EsNd70sYxExD3liwVJYqLc Rw7so1PEIFp+Ni9A1DrBR5NaJBnno2PHzHPTS9nmZVYm/4I32qkLXOcdX0XElO8VPDoVobG6 gELf4v/vIImdmxLh/w5WctUpBhWWIfQDvSOW2VZDOihm7pzhQodr3QP/GDLfpK6wI7exeu3P pfPtqwa06s1pae3ad13mZGzkBdNKs1HEm8x6zsBNBEvHyWwBCADGkMFzFjmmyqAEn5D+Mt4P zPdO8NatsDw8Qit3Rmzu+kUygxyYbz52ZO40WUu7EgQ5kDTOeRPnTOd7awWDQcl1gGBXgrkR pAlQ0l0ReO57Q0eglFydLMi5bkwYhfY+TwDPMh3aOP5qBXkm4qIYSsxb8A+i00P72AqFb9Q7 3weG/flxSPApLYQE5qWGSXjOkXJv42NGS6o6gd4RmD6Ap5e8ACo1lSMPfTpGzXlt4aRkBfvb NCfNsQikLZzFYDLbQgKBA33BDeV6vNJ9Cj0SgEGOkYyed4I6AbU0kIy1hHAm1r6+sAnEdIKj cHi3xWH/UPrZW5flM8Kqo14OTDkI9EtlABEBAAHCwF8EGAEIAAkFAkvHyWwCGwwACgkQp6Fr SiUnQ2q03wgAmRFGDeXzc58NX0NrDijUu0zx3Lns/qZ9VrkSWbNZBFjpWKaeL1fdVeE4TDGm I5mRRIsStjQzc2R9b+2VBUhlAqY1nAiBDv0Qnt+9cLiuEICeUwlyl42YdwpmY0ELcy5+u6wz mK/jxrYOpzXKDwLq5k4X+hmGuSNWWAN3gHiJqmJZPkhFPUIozZUCeEc76pS/IUN72NfprZmF Dp6/QDjDFtfS39bHSWXKVZUbqaMPqlj/z6Ugk027/3GUjHHr8WkeL1ezWepYDY7WSoXwfoAL 2UXYsMAr/uUncSKlfjvArhsej0S4zbqim2ZY6S8aRWw94J3bSvJR+Nwbs34GPTD4Pg==
- Cc: stefanha@xxxxxxxxxx, codyprime@xxxxxxxxx, jan.kiszka@xxxxxxxxxxx, berto@xxxxxxxxxx, zhang.zhanghailiang@xxxxxxxxxx, qemu-block@xxxxxxxxxx, arikalo@xxxxxxxxxxxx, pasic@xxxxxxxxxxxxx, hpoussin@xxxxxxxxxxx, anthony.perard@xxxxxxxxxx, samuel.thibault@xxxxxxxxxxxx, philmd@xxxxxxxxxx, green@xxxxxxxxxxxxxx, lvivier@xxxxxxxxxx, ehabkost@xxxxxxxxxx, xiechanglong.d@xxxxxxxxx, pl@xxxxxxx, dgilbert@xxxxxxxxxx, b.galvani@xxxxxxxxx, eric.auger@xxxxxxxxxx, alex.williamson@xxxxxxxxxx, ronniesahlberg@xxxxxxxxx, jsnow@xxxxxxxxxx, rth@xxxxxxxxxxx, kwolf@xxxxxxxxxx, andrew@xxxxxxxx, crwulff@xxxxxxxxx, sundeep.lkml@xxxxxxxxx, michael@xxxxxxxx, qemu-ppc@xxxxxxxxxx, kbastian@xxxxxxxxxxxxxxxxxxxxx, imammedo@xxxxxxxxxx, fam@xxxxxxxxxx, peter.maydell@xxxxxxxxxx, sheepdog@xxxxxxxxxxxxxx, david@xxxxxxxxxx, palmer@xxxxxxxxxx, thuth@xxxxxxxxxx, jcmvbkbc@xxxxxxxxx, den@xxxxxxxxxx, hare@xxxxxxxx, sstabellini@xxxxxxxxxx, arei.gonglei@xxxxxxxxxx, marcel.apfelbaum@xxxxxxxxx, namei.unix@xxxxxxxxx, atar4qemu@xxxxxxxxx, farman@xxxxxxxxxxxxx, amit@xxxxxxxxxx, sw@xxxxxxxxxxx, groug@xxxxxxxx, qemu-s390x@xxxxxxxxxx, qemu-arm@xxxxxxxxxx, peter.chubb@xxxxxxxxxxxx, clg@xxxxxxxx, shorne@xxxxxxxxx, qemu-riscv@xxxxxxxxxx, cohuck@xxxxxxxxxx, amarkovic@xxxxxxxxxxxx, aurelien@xxxxxxxxxxx, pburton@xxxxxxxxxxxx, sagark@xxxxxxxxxxxxxxxxx, jasowang@xxxxxxxxxx, kraxel@xxxxxxxxxx, edgar.iglesias@xxxxxxxxx, gxt@xxxxxxxxxxxxxxx, ari@xxxxxxxxxx, quintela@xxxxxxxxxx, mdroth@xxxxxxxxxxxxxxxxxx, lersek@xxxxxxxxxx, borntraeger@xxxxxxxxxx, antonynpavlov@xxxxxxxxx, dillaman@xxxxxxxxxx, joel@xxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, integration@xxxxxxxxxxx, balrogg@xxxxxxxxx, rjones@xxxxxxxxxx, Andrew.Baumann@xxxxxxxxxxxxx, mreitz@xxxxxxxxxx, walling@xxxxxxxxxxxxx, mst@xxxxxxxxxx, mark.cave-ayland@xxxxxxxxxxxx, v.maffione@xxxxxxxxx, marex@xxxxxxx, armbru@xxxxxxxxxx, marcandre.lureau@xxxxxxxxxx, alistair@xxxxxxxxxxxxx, paul.durrant@xxxxxxxxxx, pavel.dovgaluk@xxxxxxxxx, g.lettieri@xxxxxxxxxxxx, rizzo@xxxxxxxxxxxx, david@xxxxxxxxxxxxxxxxxxxxx, akrowiak@xxxxxxxxxxxxx, berrange@xxxxxxxxxx, xiaoguangrong.eric@xxxxxxxxx, pmorel@xxxxxxxxxxxxx, wencongyang2@xxxxxxxxxx, jcd@xxxxxxxxxxxxxxx, pbonzini@xxxxxxxxxx, stefanb@xxxxxxxxxxxxx
- Delivery-date: Tue, 24 Sep 2019 05:20:38 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Openpgp: preference=signencrypt
On 9/23/19 11:12 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
> ---
> scripts/coccinelle/auto-propagated-errp.cocci | 82 +++++++++++++++++++
> 1 file changed, 82 insertions(+)
> create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
>
> diff --git a/scripts/coccinelle/auto-propagated-errp.cocci
> b/scripts/coccinelle/auto-propagated-errp.cocci
> new file mode 100644
> index 0000000000..1a3f006f0b
> --- /dev/null
> +++ b/scripts/coccinelle/auto-propagated-errp.cocci
> @@ -0,0 +1,82 @@
> +@@
> +identifier fn;
> +identifier local_err;
> +@@
> +
> + fn(..., Error **errp)
> + {
> ++ ERRP_FUNCTION_BEGIN();
> + }
This doesn't catch functions where Error **errp is not the last
parameter. Some examples (some of which may need independent tweaking
in their own right for being inconsistent, although we DO want errp to
appear before any 'format, ...' arguments):
block/ssh.c:sftp_error_setg(Error **errp, BDRVSSHState *s, const char
*fs, ...)
exec.c:static void ram_block_add(RAMBlock *new_block, Error **errp, bool
shared)
Does running this Coccinelle script 2 times in a row add a second
ERRP_FUNCTION_BEGIN() line? We want it to be idempotent (no changes on
a second run). (Admittedly, I did not actually test that yet). Also, I
don't know if this can be tweaked to avoid adding the line to a function
with an empty body, maybe:
fn(..., Error **errp, ...)
{
+ ERRP_FUNCTION_BEGIN();
...
}
to only add it to a function that already has a body (thanks to the ...)
- but I'm fuzzy enough on Coccinelle that I may be saying something
totally wrong.
> +
> +@rule1@
> +identifier fn;
> +identifier local_err;
> +@@
> +
> + fn(..., Error **errp)
> + {
> + <...
> +- Error *local_err = NULL;
> + ...>
> + }
> +
> +@@
> +identifier rule1.fn;
> +identifier rule1.local_err;
> +identifier out;
> +@@
> +
> + fn(...)
> + {
> + <...
> +- goto out;
> ++ return;
> + ...>
> +- out:
> +- error_propagate(errp, local_err);
> + }
> +
> +@@
> +identifier rule1.fn;
> +identifier rule1.local_err;
> +@@
> +
> + fn(...)
> + {
> + <...
> +(
> +- error_free(local_err);
> +- local_err = NULL;
> ++ error_free_errp(errp);
> +|
> +- error_free(local_err);
> ++ error_free_errp(errp);
> +|
> +- error_report_err(local_err);
> ++ error_report_errp(errp);
> +|
> +- warn_report_err(local_err);
> ++ warn_report_errp(errp);
> +|
> +- error_propagate(errp, local_err);
> +)
> + ...>
> + }
> +
> +@@
> +identifier rule1.fn;
> +identifier rule1.local_err;
> +@@
> +
> + fn(...)
> + {
> + <...
> +(
> +- &local_err
> ++ errp
> +|
> +- local_err
> ++ *errp
> +)
> + ...>
> + }
>
Overall, the script makes sense in my reading (but no idea if it
actually catches everything we want, or if it missed something). At any
rate, once patch 7 is split into more manageable chunks, we can
definitely spot-check results to make sure they all look reasonable.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|