All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-arm@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Use error_fatal to simplify obvious fatal errors
Date: Thu, 10 Dec 2015 15:58:57 +0200	[thread overview]
Message-ID: <56698521.3040707@redhat.com> (raw)
In-Reply-To: <878u52fpn1.fsf@blackfin.pond.sub.org>

On 12/10/2015 02:34 PM, Markus Armbruster wrote:
> Marcel Apfelbaum <marcel.apfelbaum@gmail.com> writes:
>
>> On 12/10/2015 12:19 PM, Markus Armbruster wrote:
>>> Done with this admittedly crude Coccinelle semantic patch with manual
>>> burial of dead Error * variables squashed in:
>>>
>>>       @@
>>>       identifier FUN;
>>>       expression ERR, EC;
>>>       @@
>>>       -    FUN(&ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    FUN(&error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression ARG1, ERR, EC;
>>>       @@
>>>       -    FUN(ARG1, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    FUN(ARG1, &error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression ARG1, ARG2, ERR, EC;
>>>       @@
>>>       -    FUN(ARG1, ARG2, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    FUN(ARG1, ARG2, &error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression ARG1, ARG2, ARG3, ERR, EC;
>>>       @@
>>>       -    FUN(ARG1, ARG2, ARG3, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    FUN(ARG1, ARG2, ARG3, &error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression RET, ERR, EC;
>>>       @@
>>>       -    RET = FUN(&ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    RET = FUN(&error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression RET, ARG1, ERR, EC;
>>>       @@
>>>       -    RET = FUN(ARG1, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    RET = FUN(ARG1, &error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression RET, ARG1, ARG2, ERR, EC;
>>>       @@
>>>       -    RET = FUN(ARG1, ARG2, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    RET = FUN(ARG1, ARG2, &error_fatal);
>>>       @@
>>>       identifier FUN;
>>>       expression RET, ARG1, ARG2, ARG3, ERR, EC;
>>>       @@
>>>       -    RET = FUN(ARG1, ARG2, ARG3, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    RET = FUN(ARG1, ARG2, ARG3, &error_fatal);
>>>       @@
>>>       type T;
>>>       identifier FUN, RET;
>>>       expression ERR, EC;
>>>       @@
>>>       -    T RET = FUN(&ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    T RET = FUN(&error_fatal);
>>>       @@
>>>       type T;
>>>       identifier FUN, RET;
>>>       expression ARG1, ERR, EC;
>>>       @@
>>>       -    T RET = FUN(ARG1, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    T RET = FUN(ARG1, &error_fatal);
>>>       @@
>>>       type T;
>>>       identifier FUN, RET;
>>>       expression ARG1, ARG2, ERR, EC;
>>>       @@
>>>       -    T RET = FUN(ARG1, ARG2, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    T RET = FUN(ARG1, ARG2, &error_fatal);
>>>       @@
>>>       type T;
>>>       identifier FUN, RET;
>>>       expression ARG1, ARG2, ARG3, ERR, EC;
>>>       @@
>>>       -    T RET = FUN(ARG1, ARG2, ARG3, &ERR);
>>>       -    if (ERR != NULL) {
>>>       -        error_report_err(ERR);
>>>       -        exit(EC);
>>>       -    }
>>>       +    T RET = FUN(ARG1, ARG2, ARG3, &error_fatal);
>>>
>>
>> That's so cool!
>
> I'm afraid my sledgehammer approach to Coccinelle would make its
> inventors wince...
>
>> Isn't it the time to have our own Coccinelle directory
>> with scripts like this?
>
> Could do that if there's interest.
>
>>                          And to make them part of make check?
>
> I'm afraid that's not practical.  spatch solves a difficult problem, and
> takes its own sweet time to do it.

So it takes a long time to run. We could make it depend on an environment variable,
so at least the maintainers will run it :)

My point is, now we *could* have a guarantee that if anyone uses the old
way, we can catch it in time. It can be easily lost in the review process.

Anyway, it was only a thought.
Thanks,
Marcel


>
>> Is a pity to have them lost into a git comment...


  reply	other threads:[~2015-12-10 13:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 10:19 [Qemu-arm] [PATCH] Use error_fatal to simplify obvious fatal errors Markus Armbruster
2015-12-10 10:19 ` [Qemu-devel] " Markus Armbruster
2015-12-10 10:49 ` [Qemu-arm] " Paolo Bonzini
2015-12-10 10:49   ` [Qemu-devel] " Paolo Bonzini
2015-12-10 12:31   ` [Qemu-arm] " Markus Armbruster
2015-12-10 12:31     ` Markus Armbruster
2015-12-10 13:41     ` Markus Armbruster
2015-12-10 11:32 ` Marcel Apfelbaum
2015-12-10 12:34   ` [Qemu-arm] " Markus Armbruster
2015-12-10 12:34     ` Markus Armbruster
2015-12-10 13:58     ` Marcel Apfelbaum [this message]
2015-12-10 14:16       ` [Qemu-arm] " Paolo Bonzini
2015-12-10 14:16         ` Paolo Bonzini
2015-12-10 14:32       ` [Qemu-arm] " Markus Armbruster
2015-12-10 14:32         ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56698521.3040707@redhat.com \
    --to=marcel@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.