[PATCH v3] automation/eclair_analysis: deviate and|or|xor|not for MISRA C Rule 21.2

Alessandro Zucchelli posted 1 patch 5 months ago
Failed in applying to current master (apply log)
automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH v3] automation/eclair_analysis: deviate and|or|xor|not for MISRA C Rule 21.2
Posted by Alessandro Zucchelli 5 months ago
Rule 21.2 reports identifiers reserved for the C and POSIX standard
libraries: or, and, not and xor are reserved identifiers because they
constitute alternate spellings for the corresponding operators (they are
defined as macros by iso646.h); however Xen doesn't use standard library
headers, so there is no risk of overlap.

This addresses violations arising from x86_emulate/x86_emulate.c, where
label statements named as or, and and xor appear.

No functional change.

Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
Changes from v2:
Fixed patch contents as the changes from v1 and v2 were not squashed together.
---
Changes from v1:
Added deviation for 'not' identifier.
Added explanation of where these identifiers are defined, specifically in the
'iso646.h' file of the Standard Library.
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 9fa9a7f01c..14c7afb39e 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -498,6 +498,12 @@ still remain available."
 -config=MC3R1.R21.2,declarations+={safe, "!^__builtin_.*$"}
 -doc_end
 
+-doc_begin="or, and and xor are reserved identifiers because they constitute alternate
+spellings for the corresponding operators (they are defined as macros by iso646.h).
+However, Xen doesn't use standard library headers, so there is no risk of overlap."
+-config=MC3R1.R21.2,reports+={safe, "any_area(stmt(ref(kind(label)&&^(or|and|xor|not)$)))"}
+-doc_end
+
 -doc_begin="Xen does not use the functions provided by the Standard Library, but
 implements a set of functions that share the same names as their Standard Library equivalent.
 The implementation of these functions is available in source form, so the undefined, unspecified
-- 
2.34.1
Re: [PATCH v3] automation/eclair_analysis: deviate and|or|xor|not for MISRA C Rule 21.2
Posted by Stefano Stabellini 5 months ago
On Mon, 24 Jun 2024, Alessandro Zucchelli wrote:
> Rule 21.2 reports identifiers reserved for the C and POSIX standard
> libraries: or, and, not and xor are reserved identifiers because they
> constitute alternate spellings for the corresponding operators (they are
> defined as macros by iso646.h); however Xen doesn't use standard library
> headers, so there is no risk of overlap.
> 
> This addresses violations arising from x86_emulate/x86_emulate.c, where
> label statements named as or, and and xor appear.
> 
> No functional change.
> 
> Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
> Acked-by: Stefano Stabellini <sstabellini@kernel.org>

Hi Oleksii,

I am asking for a release-ack as this patch adds a deviation, the only
impact is fewer violations from the ECLAIR analysis


> ---
> Changes from v2:
> Fixed patch contents as the changes from v1 and v2 were not squashed together.
> ---
> Changes from v1:
> Added deviation for 'not' identifier.
> Added explanation of where these identifiers are defined, specifically in the
> 'iso646.h' file of the Standard Library.
> ---
>  automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
> index 9fa9a7f01c..14c7afb39e 100644
> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
> @@ -498,6 +498,12 @@ still remain available."
>  -config=MC3R1.R21.2,declarations+={safe, "!^__builtin_.*$"}
>  -doc_end
>  
> +-doc_begin="or, and and xor are reserved identifiers because they constitute alternate
> +spellings for the corresponding operators (they are defined as macros by iso646.h).
> +However, Xen doesn't use standard library headers, so there is no risk of overlap."
> +-config=MC3R1.R21.2,reports+={safe, "any_area(stmt(ref(kind(label)&&^(or|and|xor|not)$)))"}
> +-doc_end
> +
>  -doc_begin="Xen does not use the functions provided by the Standard Library, but
>  implements a set of functions that share the same names as their Standard Library equivalent.
>  The implementation of these functions is available in source form, so the undefined, unspecified
> -- 
> 2.34.1
>
Re: [PATCH v3] automation/eclair_analysis: deviate and|or|xor|not for MISRA C Rule 21.2
Posted by Oleksii 4 months, 4 weeks ago
On Mon, 2024-06-24 at 17:22 -0700, Stefano Stabellini wrote:
> On Mon, 24 Jun 2024, Alessandro Zucchelli wrote:
> > Rule 21.2 reports identifiers reserved for the C and POSIX standard
> > libraries: or, and, not and xor are reserved identifiers because
> > they
> > constitute alternate spellings for the corresponding operators
> > (they are
> > defined as macros by iso646.h); however Xen doesn't use standard
> > library
> > headers, so there is no risk of overlap.
> > 
> > This addresses violations arising from x86_emulate/x86_emulate.c,
> > where
> > label statements named as or, and and xor appear.
> > 
> > No functional change.
> > 
> > Signed-off-by: Alessandro Zucchelli
> > <alessandro.zucchelli@bugseng.com>
> > Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> Hi Oleksii,
Hi Stefano,

> 
> I am asking for a release-ack as this patch adds a deviation, the
> only
> impact is fewer violations from the ECLAIR analysis
Looks good to me:
 Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

~ Oleksii

> 
> 
> > ---
> > Changes from v2:
> > Fixed patch contents as the changes from v1 and v2 were not
> > squashed together.
> > ---
> > Changes from v1:
> > Added deviation for 'not' identifier.
> > Added explanation of where these identifiers are defined,
> > specifically in the
> > 'iso646.h' file of the Standard Library.
> > ---
> >  automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl
> > b/automation/eclair_analysis/ECLAIR/deviations.ecl
> > index 9fa9a7f01c..14c7afb39e 100644
> > --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
> > +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
> > @@ -498,6 +498,12 @@ still remain available."
> >  -config=MC3R1.R21.2,declarations+={safe, "!^__builtin_.*$"}
> >  -doc_end
> >  
> > +-doc_begin="or, and and xor are reserved identifiers because they
> > constitute alternate
> > +spellings for the corresponding operators (they are defined as
> > macros by iso646.h).
> > +However, Xen doesn't use standard library headers, so there is no
> > risk of overlap."
> > +-config=MC3R1.R21.2,reports+={safe,
> > "any_area(stmt(ref(kind(label)&&^(or|and|xor|not)$)))"}
> > +-doc_end
> > +
> >  -doc_begin="Xen does not use the functions provided by the
> > Standard Library, but
> >  implements a set of functions that share the same names as their
> > Standard Library equivalent.
> >  The implementation of these functions is available in source form,
> > so the undefined, unspecified
> > -- 
> > 2.34.1
> >