[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
- To: Eric Blake <eblake@xxxxxxxxxx>, "qemu-devel@xxxxxxxxxx" <qemu-devel@xxxxxxxxxx>
- From: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
- Date: Mon, 14 Oct 2019 08:19:49 +0000
- Accept-language: ru-RU, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LqWzROTW11e8FonVvvq50XA/3CzppCV8wRKb9jcx3DU=; b=CCtMKwnGzbXPEiA58PkeaYxTHT/IKJxskdrRfyHcFRJxdJ0Nhp1MzDjX4N0LSoDG9uZxg1FAN0jLY+TSF9OTfNLjQ1qKz4qq5pO9K6qTciHImm5+uFnMUwmnRS9Gg1QKaNBZUf/wKyHcMVfdTFULpOYDumgC/fiyR8p0NznHJUshMyhKTsKMyQEnpnaSdf/jMxh/fH6dej4rmjkdgrC+NwhAuuJlRgmFz1hLrBjq5A8DApeI8KkUh4j0hmr8O0Tjf9SQCVrrAJkZxPiCC33gF5X8bZ02ajpSyItYjrDCl4pZNWSTKE0VcIqo67txxc5r6ABQeY078SHeU97WDgAt4Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BpYmI0pS+0yJ7cV2vP4UwNTcd9lZAAURTOhu+VfX5cDYe6M/th0UuEDdQCRfv5HbAMP+dAOoe7ZnAyW1CqTHSRsw++ruJ1ciDBHvK05aeHhj5q/ZSVQIFPCDm2js88PSgqi/b9AznvX/1A52wsEU2OGPNAk0MY8AFTmTzsDiSVRVITXzvFMna/8cmIYkJDXiV0B/imRVaq5mPmlcTMz+RdHW51pU+3NQ91yuhrZUt9iqUdgbLFBMaAtS0ox3lCAs/j8PxUhg0g0yPbLPhoViiBpwea49KYCLKmUiZJKBkz9d+tnnB28NJitSnb66edJak+hfyNnWcvjYbCW2s3c+PQ==
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vsementsov@xxxxxxxxxxxxx;
- Cc: Stefan Hajnoczi <stefanha@xxxxxxxxxx>, Jeff Cody <codyprime@xxxxxxxxx>, Jan Kiszka <jan.kiszka@xxxxxxxxxxx>, Alberto Garcia <berto@xxxxxxxxxx>, Hailiang Zhang <zhang.zhanghailiang@xxxxxxxxxx>, "qemu-block@xxxxxxxxxx" <qemu-block@xxxxxxxxxx>, Aleksandar Rikalo <arikalo@xxxxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Hervé Poussineau <hpoussin@xxxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>, Anthony Green <green@xxxxxxxxxxxxxx>, Laurent Vivier <lvivier@xxxxxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>, Xie Changlong <xiechanglong.d@xxxxxxxxx>, Peter Lieven <pl@xxxxxxx>, "Dr. David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Beniamino Galvani <b.galvani@xxxxxxxxx>, Eric Auger <eric.auger@xxxxxxxxxx>, Alex Williamson <alex.williamson@xxxxxxxxxx>, Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Richard Henderson <rth@xxxxxxxxxxx>, Kevin Wolf <kwolf@xxxxxxxxxx>, Andrew Jeffery <andrew@xxxxxxxx>, Chris Wulff <crwulff@xxxxxxxxx>, Subbaraya Sundeep <sundeep.lkml@xxxxxxxxx>, Michael Walle <michael@xxxxxxxx>, "qemu-ppc@xxxxxxxxxx" <qemu-ppc@xxxxxxxxxx>, Bastian Koppelmann <kbastian@xxxxxxxxxxxxxxxxxxxxx>, Igor Mammedov <imammedo@xxxxxxxxxx>, Fam Zheng <fam@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, "sheepdog@xxxxxxxxxxxxxx" <sheepdog@xxxxxxxxxxxxxx>, Matthew Rosato <mjrosato@xxxxxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxx>, Thomas Huth <thuth@xxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Hannes Reinecke <hare@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Gonglei \(Arei\)" <arei.gonglei@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Liu Yuan <namei.unix@xxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Eric Farman <farman@xxxxxxxxxxxxx>, Amit Shah <amit@xxxxxxxxxx>, Stefan Weil <sw@xxxxxxxxxxx>, Greg Kurz <groug@xxxxxxxx>, Yuval Shaia <yuval.shaia@xxxxxxxxxx>, "qemu-s390x@xxxxxxxxxx" <qemu-s390x@xxxxxxxxxx>, "qemu-arm@xxxxxxxxxx" <qemu-arm@xxxxxxxxxx>, Peter Chubb <peter.chubb@xxxxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Stafford Horne <shorne@xxxxxxxxx>, "qemu-riscv@xxxxxxxxxx" <qemu-riscv@xxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, Aleksandar Markovic <amarkovic@xxxxxxxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>, Paul Burton <pburton@xxxxxxxxxxxx>, Sagar Karandikar <sagark@xxxxxxxxxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Jason Wang <jasowang@xxxxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Guan Xuetao <gxt@xxxxxxxxxxxxxxx>, Ari Sundholm <ari@xxxxxxxxxx>, Juan Quintela <quintela@xxxxxxxxxx>, Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxx>, Joel Stanley <joel@xxxxxxxxx>, Jason Dillaman <dillaman@xxxxxxxxxx>, Antony Pavlov <antonynpavlov@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "integration@xxxxxxxxxxx" <integration@xxxxxxxxxxx>, Laszlo Ersek <lersek@xxxxxxxxxx>, "Richard W.M. Jones" <rjones@xxxxxxxxxx>, Andrew Baumann <Andrew.Baumann@xxxxxxxxxxxxx>, Max Reitz <mreitz@xxxxxxxxxx>, Denis Lunev <den@xxxxxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Vincenzo Maffione <v.maffione@xxxxxxxxx>, Marek Vasut <marex@xxxxxxx>, "armbru@xxxxxxxxxx" <armbru@xxxxxxxxxx>, Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Pavel Dovgalyuk <pavel.dovgaluk@xxxxxxxxx>, Giuseppe Lettieri <g.lettieri@xxxxxxxxxxxx>, Luigi Rizzo <rizzo@xxxxxxxxxxxx>, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, Tony Krowiak <akrowiak@xxxxxxxxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, Xiao Guangrong <xiaoguangrong.eric@xxxxxxxxx>, Pierre Morel <pmorel@xxxxxxxxxxxxx>, Wen Congyang <wencongyang2@xxxxxxxxxx>, Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Stefan Berger <stefanb@xxxxxxxxxxxxx>
- Delivery-date: Mon, 14 Oct 2019 08:26:36 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHVgE3Yxrwb2TPU1UWX1rcryXdDAKdVrZuAgAQiCQA=
- Thread-topic: [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
11.10.2019 20:12, Eric Blake wrote:
> On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
>> ---
>>
>
>> scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++++++++++++
>> 1 file changed, 118 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..d9731620aa
>> --- /dev/null
>> +++ b/scripts/coccinelle/auto-propagated-errp.cocci
>
>> +@rule1@
>> +// Drop local_err
>> +identifier fn, local_err;
>> +symbol errp;
>> +@@
>> +
>> + fn(..., Error **errp, ...)
>> + {
>> + <...
>> +- Error *local_err = NULL;
>> + ...>
>> + }
>> +
>
> So our goal is to automate removal of all local_err (including when it is
> spelled err)...
>
>> +@@
>> +// Handle pattern with goto, otherwise we'll finish up
>> +// with labels at function end which will not compile.
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +identifier OUT;
>> +@@
>> +
>> + fn(...)
>> + {
>> + <...
>> +- goto OUT;
>> ++ return;
>> + ...>
>> +- OUT:
>> +- error_propagate(errp, local_err);
>> + }
>> +
>
> this dangling label cleanup makes sense
>
>> +@@
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +@@
>> +
>> + fn(...)
>> + {
>> + <...
>> +(
>> +- error_free(local_err);
>> +- local_err = NULL;
>> ++ error_free_errp(errp);
>
> This does not make sense - error_free_errp() is not defined prior to this
> series or anywhere in patches 1-24, if I'm reading it correctly.
>
>> +|
>> +- error_free(local_err);
>> ++ error_free_errp(errp);
>
> and again
>
>> +|
>> +- error_report_err(local_err);
>> ++ error_report_errp(errp);
>> +|
>> +- warn_report_err(local_err);
>> ++ warn_report_errp(errp);
>> +|
>> +- error_propagate_prepend(errp, local_err,
>> ++ error_prepend(errp,
>> + ...);
>> +|
>> +- error_propagate(errp, local_err);
>> +)
>> + ...>
>> + }
>> +
>
> It looks like once this script is run, error_propagate_prepend() will have no
> clients.
No, it still have a bit, when working with error_copy, and/or moving errors
from/to structures.
> Is there a non-generated cleanup patch that removes it (and once it is
> removed, it can also be removed from the .cocci script as no further clients
> will reappear later)?
Maybe.
>
>
>> +@@
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +@@
>> +
>> + fn(...)
>> + {
>> + <...
>> +(
>> +- &local_err
>> ++ errp
>> +|
>> +- local_err
>> ++ *errp
>> +)
>> + ...>
>> + }
>> +
>> +@@
>> +symbol errp;
>> +@@
>> +
>> +- *errp != NULL
>> ++ *errp
>>
>
> Seems to make sense.
>
--
Best regards,
Vladimir
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|