From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Julien Grall <julien@xen.org>
Cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org,
michal.orzel@amd.com, xenia.ragiadakou@amd.com,
ayan.kumar.halder@amd.com, consulting@bugseng.com,
jbeulich@suse.com, andrew.cooper3@citrix.com,
roger.pau@citrix.com,
Simone Ballarin <simone.ballarin@bugseng.com>,
Doug Goldstein <cardoe@cardoe.com>,
George Dunlap <george.dunlap@citrix.com>, Wei Liu <wl@xen.org>
Subject: Re: [RFC PATCH 4/4] automation/eclair: add deviation for certain backwards goto
Date: Tue, 07 Nov 2023 15:45:52 +0100 [thread overview]
Message-ID: <31d0509acf5a31351d6efa7c66710729@bugseng.com> (raw)
In-Reply-To: <a95c6666-dbf3-4f1f-9618-b1f31bf47710@xen.org>
Hi Julien,
On 2023-11-07 13:44, Julien Grall wrote:
> Hi Nicola,
>
> On 07/11/2023 10:33, Nicola Vetrini wrote:
>> As explained in the deviation record, code constructs such as
>> "goto retry" and "goto again" are sometimes the best balance between
>> code complexity and the understandability of the control flow
>> by developers; as such, these construct are allowed to deviate
>> from Rule 15.2.
>>
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> ---
>> automation/eclair_analysis/ECLAIR/deviations.ecl | 10 ++++++++++
>> docs/misra/deviations.rst | 10 ++++++++++
>> 2 files changed, 20 insertions(+)
>>
>> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl
>> b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> index fa56e5c00a27..8b1f622f8f82 100644
>> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
>> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> @@ -270,6 +270,16 @@ statements are deliberate"
>> -config=MC3R1.R14.3,statements={deliberate ,
>> "wrapped(any(),node(if_stmt))" }
>> -doc_end
>> +#
>> +# Series 15
>> +#
>> +
>> +-doc_begin="The additional complexity introduced in the code by using
>> control flow structures other than backwards goto-s
>> +were deemed not to justify the possible prevention of developer
>> confusion, given the very torough review process estabilished
>
> Typoes: s/torough/thorough/ s/estabilished/established/
>
Thanks
>> +in the community."
>> +-config=MC3R1.R15.2,reports+={deliberate,
>> "any_area(any_loc(text(^.*goto (again|retry).*$)))"}
>> +-doc_end
>> +
>> #
>> # Series 20.
>> #
>> diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
>> index 8511a189253b..7d1e1f0d09b3 100644
>> --- a/docs/misra/deviations.rst
>> +++ b/docs/misra/deviations.rst
>> @@ -208,6 +208,16 @@ Deviations related to MISRA C:2012 Rules:
>> statements are deliberate.
>> - Project-wide deviation; tagged as `disapplied` for ECLAIR.
>> + * - R15.2
>> + - The possible prevention of developer confusion as a result of
>> using
>> + control flow structures other than backwards goto-s in some
>> instances was
>> + deemed not strong enough to justify the additional complexity
>> introduced
>> + in the code. Such instances are the uses of the following
>> labels:
>> +
>> + - again
>> + - retry
>
> Have you investigated the possibility to use SAF-X in the code? If so,
> what's the problem to use them?
>
> Cheers,
This is another viable option: putting the SAF comment on top of the
label should suffice,
as shown below:
/* SAF-2-safe */
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
I think it ultimately boils down to whether Xen wants to promote the use
of certain labels
as the designated alternative when no other control flow mechanism is
clearer from a
readability perspective (in which case there should be a consistent
naming to capture and deviate
all of them, such as "retry") or do so on a case-by-case basis with a
SAF, which is ok, but then
it needs someone to check each one and either fix them or mark them as
ok.
Yet another route could be to mark with a SAF all those present right
now to establish a baseline.
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
next prev parent reply other threads:[~2023-11-07 14:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 10:33 [RFC PATCH 0/4] address MISRA C:2012 Rule 15.2 Nicola Vetrini
2023-11-07 10:33 ` [RFC PATCH 1/4] xen/vsprintf: replace backwards jump with loop Nicola Vetrini
2023-11-07 11:36 ` Andrew Cooper
2023-11-21 13:52 ` Jan Beulich
2023-11-07 10:33 ` [RFC PATCH 2/4] x86/dom0: make goto jump forward Nicola Vetrini
2023-11-21 13:57 ` Jan Beulich
2023-11-07 10:33 ` [RFC PATCH 3/4] xen/arm: GICv3: address MISRA C:2012 Rule 15.2 Nicola Vetrini
2023-11-07 12:34 ` Julien Grall
2023-11-07 10:33 ` [RFC PATCH 4/4] automation/eclair: add deviation for certain backwards goto Nicola Vetrini
2023-11-07 12:44 ` Julien Grall
2023-11-07 14:45 ` Nicola Vetrini [this message]
2023-11-07 17:35 ` Julien Grall
2023-11-08 10:10 ` Nicola Vetrini
2023-11-07 10:52 ` [RFC PATCH 0/4] address MISRA C:2012 Rule 15.2 Jan Beulich
2023-11-07 11:10 ` Nicola Vetrini
2023-11-21 14:41 ` Nicola Vetrini
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=31d0509acf5a31351d6efa7c66710729@bugseng.com \
--to=nicola.vetrini@bugseng.com \
--cc=andrew.cooper3@citrix.com \
--cc=ayan.kumar.halder@amd.com \
--cc=cardoe@cardoe.com \
--cc=consulting@bugseng.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=simone.ballarin@bugseng.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
--cc=xenia.ragiadakou@amd.com \
/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.