Message ID | a9027b582d7866a31d7438d083499c53a3245989.1709305397.git.federico.serafini@bugseng.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [XEN] automation/eclair: add deviation for MISRA C:2012 Rule 16.6 | expand |
On Fri, 1 Mar 2024, Federico Serafini wrote: > Update ECLAIR configuration to take into account the deviations > agreed during MISRA meetings. > > Signed-off-by: Federico Serafini <federico.serafini@bugseng.com> Acked-by: Stefano Stabellini <sstabellini@kernel.org> > --- > automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ > docs/misra/deviations.rst | 6 ++++++ > 2 files changed, 10 insertions(+) > > diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl > index 02eae39786..0e62a7029f 100644 > --- a/automation/eclair_analysis/ECLAIR/deviations.ecl > +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl > @@ -378,6 +378,10 @@ explicit comment indicating the fallthrough intention is present." > -config=MC3R1.R16.3,reports+={safe, "any_area(end_loc(any_exp(text(^(?s).*/\\* [fF]all ?through.? \\*/.*$,0..1))))"} > -doc_end > > +-doc_begin="A switch statement with a single switch clause and no default label is deliberate and improves readability with respect to an equivalent if statement." > +-config=MC3R1.R16.6,switch_clauses+={deliberate, "default(0)"} > +-doc_end > + > # > # Series 18. > # > diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst > index 123c78e20a..041f8db4ee 100644 > --- a/docs/misra/deviations.rst > +++ b/docs/misra/deviations.rst > @@ -322,6 +322,12 @@ Deviations related to MISRA C:2012 Rules: > - /\* Fallthrough \*/ > - /\* Fallthrough. \*/ > > + * - R16.6 > + - A switch statement with a single switch clause and no default label is > + deliberate and improves readability with respect to an equivalent if > + statement. > + - Tagged as `deliberate` for ECLAIR. > + > * - R20.7 > - Code violating Rule 20.7 is safe when macro parameters are used: > (1) as function arguments; > -- > 2.34.1 >
On 01.03.2024 16:04, Federico Serafini wrote: > --- a/docs/misra/deviations.rst > +++ b/docs/misra/deviations.rst > @@ -322,6 +322,12 @@ Deviations related to MISRA C:2012 Rules: > - /\* Fallthrough \*/ > - /\* Fallthrough. \*/ > > + * - R16.6 > + - A switch statement with a single switch clause and no default label is > + deliberate and improves readability with respect to an equivalent if > + statement. > + - Tagged as `deliberate` for ECLAIR. Imo this is another example of wording a deviation in too wide a manner. It shouldn't be "is", but "may". Whether what is said here applies is entirely down to every specific instance; otherwise I'm inclined to read this as a suggestion to replace all if() by switch(), for that always improving readability. FTAOD things would be different if this was explanatory text to a SAF comment - there the specific context is always given (by where the comment actually appears). Jan
On 04/03/24 09:04, Jan Beulich wrote: > On 01.03.2024 16:04, Federico Serafini wrote: >> --- a/docs/misra/deviations.rst >> +++ b/docs/misra/deviations.rst >> @@ -322,6 +322,12 @@ Deviations related to MISRA C:2012 Rules: >> - /\* Fallthrough \*/ >> - /\* Fallthrough. \*/ >> >> + * - R16.6 >> + - A switch statement with a single switch clause and no default label is >> + deliberate and improves readability with respect to an equivalent if >> + statement. >> + - Tagged as `deliberate` for ECLAIR. > > Imo this is another example of wording a deviation in too wide a manner. > It shouldn't be "is", but "may". Whether what is said here applies is > entirely down to every specific instance; otherwise I'm inclined to read > this as a suggestion to replace all if() by switch(), for that always > improving readability. FTAOD things would be different if this was > explanatory text to a SAF comment - there the specific context is always > given (by where the comment actually appears). Ok, I'll rephrase a v2.
diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index 02eae39786..0e62a7029f 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -378,6 +378,10 @@ explicit comment indicating the fallthrough intention is present." -config=MC3R1.R16.3,reports+={safe, "any_area(end_loc(any_exp(text(^(?s).*/\\* [fF]all ?through.? \\*/.*$,0..1))))"} -doc_end +-doc_begin="A switch statement with a single switch clause and no default label is deliberate and improves readability with respect to an equivalent if statement." +-config=MC3R1.R16.6,switch_clauses+={deliberate, "default(0)"} +-doc_end + # # Series 18. # diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index 123c78e20a..041f8db4ee 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -322,6 +322,12 @@ Deviations related to MISRA C:2012 Rules: - /\* Fallthrough \*/ - /\* Fallthrough. \*/ + * - R16.6 + - A switch statement with a single switch clause and no default label is + deliberate and improves readability with respect to an equivalent if + statement. + - Tagged as `deliberate` for ECLAIR. + * - R20.7 - Code violating Rule 20.7 is safe when macro parameters are used: (1) as function arguments;
Update ECLAIR configuration to take into account the deviations agreed during MISRA meetings. Signed-off-by: Federico Serafini <federico.serafini@bugseng.com> --- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ docs/misra/deviations.rst | 6 ++++++ 2 files changed, 10 insertions(+)