qemu-arm
[Top][All Lists]
Advanced

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

Re: [Qemu-arm] [Qemu-devel] [PATCH] Use error_fatal to simplify obvious


From: Markus Armbruster
Subject: Re: [Qemu-arm] [Qemu-devel] [PATCH] Use error_fatal to simplify obvious fatal errors
Date: Thu, 10 Dec 2015 13:34:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Marcel Apfelbaum <address@hidden> 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.

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



reply via email to

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