From nobody Sat Feb 7 08:49:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1714730362116905.8478129394266; Fri, 3 May 2024 02:59:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.716316.1118419 (Exim 4.92) (envelope-from ) id 1s2pgt-0002F7-Gl; Fri, 03 May 2024 09:58:55 +0000 Received: by outflank-mailman (output) from mailman id 716316.1118419; Fri, 03 May 2024 09:58:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s2pgt-0002EG-DZ; Fri, 03 May 2024 09:58:55 +0000 Received: by outflank-mailman (input) for mailman id 716316; Fri, 03 May 2024 09:58:54 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s2pgs-0002BX-Oq for xen-devel@lists.xenproject.org; Fri, 03 May 2024 09:58:54 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bef5dcdc-0933-11ef-b4bb-af5377834399; Fri, 03 May 2024 11:58:52 +0200 (CEST) Received: from truciolo.homenet.telecomitalia.it (host-79-36-52-167.retail.telecomitalia.it [79.36.52.167]) by support.bugseng.com (Postfix) with ESMTPSA id EEE5F4EE074A; Fri, 3 May 2024 11:58:51 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bef5dcdc-0933-11ef-b4bb-af5377834399 From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH 1/2] docs/misra: add Terms & Definitions section to rules.rst Date: Fri, 3 May 2024 11:58:43 +0200 Message-Id: <05d9d4b4319f28d602b7366f2964c451a3a50ce3.1714727807.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1714730362927100001 Content-Type: text/plain; charset="utf-8" Add a section for terms and definitions used by MISRA but expressed in terms of the C specification. Add a definition of "switch clause" to the newly-introduced section. Link the first use of the term "switch clause" in the document to its definition. Suggested-by: Jan Beulich Signed-off-by: Federico Serafini Reviewed-by: Stefano Stabellini --- Jan you were not completely satisfied by the definition but I didn't find a better one. --- docs/misra/rules.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index b7b447e152..d3b70fdf04 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -489,8 +489,7 @@ maintainers if you want to suggest a change. =20 * - `Rule 16.3 `_ - Required - - An unconditional break statement shall terminate every - switch-clause + - An unconditional break statement shall terminate every switch-claus= e_ - In addition to break, also other unconditional flow control stateme= nts such as continue, return, goto are allowed. =20 @@ -712,3 +711,14 @@ maintainers if you want to suggest a change. - The value of a pointer to a FILE shall not be used after the associ= ated stream has been closed - + +Terms & Definitions +------------------- + +.. _switch-clause: + +A *switch clause* can be defined as: +"the non-empty list of statements which follows a non-empty list of +case/default labels". +A formal definition is available within the amplification of MISRA C:2012 +Rule 16.1. --=20 2.34.1 From nobody Sat Feb 7 08:49:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1714730372383896.479188368713; Fri, 3 May 2024 02:59:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.716317.1118434 (Exim 4.92) (envelope-from ) id 1s2pgu-0002eL-MT; Fri, 03 May 2024 09:58:56 +0000 Received: by outflank-mailman (output) from mailman id 716317.1118434; Fri, 03 May 2024 09:58:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s2pgu-0002eE-Jv; Fri, 03 May 2024 09:58:56 +0000 Received: by outflank-mailman (input) for mailman id 716317; Fri, 03 May 2024 09:58:55 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s2pgt-0002BX-DB for xen-devel@lists.xenproject.org; Fri, 03 May 2024 09:58:55 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bf38cf39-0933-11ef-b4bb-af5377834399; Fri, 03 May 2024 11:58:52 +0200 (CEST) Received: from truciolo.homenet.telecomitalia.it (host-79-36-52-167.retail.telecomitalia.it [79.36.52.167]) by support.bugseng.com (Postfix) with ESMTPSA id 5A7FE4EE074D; Fri, 3 May 2024 11:58:52 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bf38cf39-0933-11ef-b4bb-af5377834399 From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Simone Ballarin , Doug Goldstein , Stefano Stabellini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall Subject: [XEN PATCH 2/2] automation/eclair: add deviation for Rule 16.4 Date: Fri, 3 May 2024 11:58:44 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1714730372780100001 Content-Type: text/plain; charset="utf-8" MISRA C:2012 Rule 16.4 states that "Every switch statement shall have a default label". Update ECLAIR configuration to take into account the deviations agreed during MISRA meetings. Signed-off-by: Federico Serafini Reviewed-by: Stefano Stabellini --- automation/eclair_analysis/ECLAIR/deviations.ecl | 8 ++++++++ docs/misra/deviations.rst | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index d21f112a9b..f09ad71acf 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -384,6 +384,14 @@ explicit comment indicating the fallthrough intention = is present." -config=3DMC3R1.R16.3,reports+=3D{safe, "any_area(end_loc(any_exp(text(^(?= s).*/\\* [fF]all ?through.? \\*/.*$,0..1))))"} -doc_end =20 +-doc_begin=3D"Switch statements having a controlling expression of enum ty= pe deliberately do not have a default case: gcc -Wall enables -Wswitch whic= h warns (and breaks the build as we use -Werror) if one of the enum labels = is missing from the switch." +-config=3DMC3R1.R16.4,reports+=3D{deliberate,'any_area(kind(context)&&^.* = has no `default.*$&&stmt(node(switch_stmt)&&child(cond,skip(__non_syntactic= _paren_stmts,type(canonical(enum_underlying_type(any())))))))'} +-doc_end + +-doc_begin=3D"A switch statement with a single switch clause and no defaul= t label may be used in place of an equivalent if statement if it is conside= red to improve readability." +-config=3DMC3R1.R16.4,switch_clauses+=3D{deliberate,"switch(1)&&default(0)= "} +-doc_end + -doc_begin=3D"A switch statement with a single switch clause and no defaul= t label may be used in place of an equivalent if statement if it is conside= red to improve readability." -config=3DMC3R1.R16.6,switch_clauses+=3D{deliberate, "default(0)"} -doc_end diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index ed0c1e8ed0..39cc321a27 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -334,6 +334,19 @@ Deviations related to MISRA C:2012 Rules: - /\* Fallthrough \*/ - /\* Fallthrough. \*/ =20 + * - R16.4 + - Switch statements having a controlling expression of enum type + deliberately do not have a default case: gcc -Wall enables -Wswitch + which warns (and breaks the build as we use -Werror) if one of the = enum + labels is missing from the switch. + - Tagged as `deliberate` for ECLAIR. + + * - R16.4 + - A switch statement with a single switch clause and no default label= may + be used in place of an equivalent if statement if it is considered = to + improve readability. + - Tagged as `deliberate` for ECLAIR. + * - R16.6 - A switch statement with a single switch clause and no default label= may be used in place of an equivalent if statement if it is considered = to --=20 2.34.1