From patchwork Tue Apr 23 10:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13639690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54827C4345F for ; Tue, 23 Apr 2024 10:03:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.710495.1109738 (Exim 4.92) (envelope-from ) id 1rzCz8-0002Xo-2u; Tue, 23 Apr 2024 10:02:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 710495.1109738; Tue, 23 Apr 2024 10:02:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzCz7-0002Xh-TW; Tue, 23 Apr 2024 10:02:45 +0000 Received: by outflank-mailman (input) for mailman id 710495; Tue, 23 Apr 2024 10:02:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzCz6-0002XV-9Y for xen-devel@lists.xenproject.org; Tue, 23 Apr 2024 10:02:44 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a031a933-0158-11ef-909a-e314d9c70b13; Tue, 23 Apr 2024 12:02:43 +0200 (CEST) Received: from truciolo.home-life.hub (unknown [176.206.12.122]) by support.bugseng.com (Postfix) with ESMTPSA id 2475B4EE073E; Tue, 23 Apr 2024 12:02:42 +0200 (CEST) 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: a031a933-0158-11ef-909a-e314d9c70b13 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] automation/eclair: add deviations for MISRA C:2012 Rule 16.4 Date: Tue, 23 Apr 2024 12:02:36 +0200 Message-Id: <4981c3fb0992898a121881333485004f3609eaf7.1713866519.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Update ECLAIR configuration to take into account the deviations agreed during MISRA meetings for Rule 16.4. Signed-off-by: Federico Serafini --- 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=MC3R1.R16.3,reports+={safe, "any_area(end_loc(any_exp(text(^(?s).*/\\* [fF]all ?through.? \\*/.*$,0..1))))"} -doc_end +-doc_begin="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." +-config=MC3R1.R16.4,reports+={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="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." +-config=MC3R1.R16.4,switch_clauses+={deliberate,"switch(1)&&default(0)"} +-doc_end + -doc_begin="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." -config=MC3R1.R16.6,switch_clauses+={deliberate, "default(0)"} -doc_end diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index ed0c1e8ed0..df87239b7d 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -302,6 +302,19 @@ Deviations related to MISRA C:2012 Rules: leave such files as is. - Tagged as `deliberate` for ECLAIR. + * - 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.3 - Switch clauses ending with continue, goto, return statements are safe. - Tagged as `safe` for ECLAIR.