[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGA
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE() |
Date: |
Thu, 19 Mar 2020 09:31:17 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Vladimir Sementsov-Ogievskiy <address@hidden> writes:
> 14.03.2020 0:54, Markus Armbruster wrote:
[...]
>> // Match functions with propagation of local error to errp.
>> // We want to refer these functions in several following rules, but I
>> // don't know a proper way to inherit a function, not just its name
>> // (to not match another functions with same name in following rules).
>> // Not-proper way is as follows: rename errp parameter in functions
>> // header and match it in following rules. Rename it back after all
>> // transformations.
>> //
>> // The simplest case of propagation scheme is single definition of
>> // local_err with at most one error_propagate_prepend or
>> // error_propagate on each control-flow. Still, we want to match more
>> // complex schemes too. We'll warn them with help of further rules.
>> @rule1 disable optional_qualifier exists@
>> identifier fn, local_err;
>> symbol errp;
>> @@
>>
>> fn(..., Error **
>> - errp
>> + ____
>> , ...)
>> {
>> ...
>> Error *local_err = NULL;
>> ...
>> (
>> error_propagate_prepend(errp, local_err, ...);
>> |
>> error_propagate(errp, local_err);
>> )
>> ...
>> }
>>
>>
>> // Warn several Error * definitions.
>> @check1 disable optional_qualifier exists@
>> identifier fn, _errp, local_err, local_err2;
>> position p1, p2;
>> @@
>>
>> fn(..., Error **_errp, ...)
>> {
>> ...
>> Error *local_err = NULL;@p1
>> ... when any
>> Error *local_err2 = NULL;@p2
>> ... when any
>> }
>>
>> @ script:python @
>> fn << check1.fn;
>> p1 << check1.p1;
>> p2 << check1.p2;
>> @@
>>
>> print('Warning: function {} has several definitions of '
>> 'Error * local variable: at {}:{} and then at {}:{}'.format(
>> fn, p1[0].file, p1[0].line, p2[0].file, p2[0].line))
>>
>> // Warn several propagations in control flow.
>> @check2 disable optional_qualifier exists@
>> identifier fn, _errp;
>> position p1, p2;
>> @@
>>
>> fn(..., Error **_errp, ...)
>
> Hmm, for this to work, we should move the rule above rule1, because now
> paramter
> definition is different from it usage in the function body.
I think you're right.
[...]
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), (continued)
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/16
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Vladimir Sementsov-Ogievskiy, 2020/03/17
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/17
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Vladimir Sementsov-Ogievskiy, 2020/03/17
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/19
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Vladimir Sementsov-Ogievskiy, 2020/03/19
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/20
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Vladimir Sementsov-Ogievskiy, 2020/03/20
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/20
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Vladimir Sementsov-Ogievskiy, 2020/03/17
- Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(),
Markus Armbruster <=
Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/13
Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE(), Markus Armbruster, 2020/03/13
Re: [PATCH v9 00/10] error: auto propagated local_err part I, Markus Armbruster, 2020/03/12