From patchwork Mon Jun 17 08:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13700330 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 8465CC27C7B for ; Mon, 17 Jun 2024 08:57:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.741921.1148625 (Exim 4.92) (envelope-from ) id 1sJ8B9-0005yf-T4; Mon, 17 Jun 2024 08:57:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 741921.1148625; Mon, 17 Jun 2024 08:57:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sJ8B9-0005tw-Mv; Mon, 17 Jun 2024 08:57:31 +0000 Received: by outflank-mailman (input) for mailman id 741921; Mon, 17 Jun 2024 08:57:30 +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 1sJ8B8-0005Fp-5w for xen-devel@lists.xenproject.org; Mon, 17 Jun 2024 08:57:30 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9f1aff13-2c87-11ef-90a3-e314d9c70b13; Mon, 17 Jun 2024 10:57:27 +0200 (CEST) Received: from nico.bugseng.com (unknown [46.228.253.194]) by support.bugseng.com (Postfix) with ESMTPSA id B22044EE0759; Mon, 17 Jun 2024 10:57:26 +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: 9f1aff13-2c87-11ef-90a3-e314d9c70b13 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, Nicola Vetrini , Simone Ballarin , Doug Goldstein , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall Subject: [XEN PATCH v2 4/6][RESEND] automation/eclair_analysis: address violations of MISRA C Rule 20.7 Date: Mon, 17 Jun 2024 10:57:16 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 MISRA C Rule 20.7 states: "Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses". The local helpers GRP2 and XADD in the x86 emulator use their first argument as the constant expression for a case label. This pattern is deviated project-wide, because it is very unlikely to induce developer confusion and result in the wrong control flow being carried out. No functional change. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- Changes in v2: - Introduce a deviation instead of adding parentheses --- automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++-- docs/misra/deviations.rst | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index c2698e7074aa..fc248641dc78 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -428,13 +428,15 @@ unexpected result when the structure is given as argument to a sizeof() operator -doc_begin="Code violating Rule 20.7 is safe when macro parameters are used: (1) as function arguments; (2) as macro arguments; (3) as array indices; (4) as lhs -in assignments; (5) as initializers, possibly designated, in initalizer lists." +in assignments; (5) as initializers, possibly designated, in initalizer lists; +(6) as the constant expression in a switch clause label." -config=MC3R1.R20.7,expansion_context= {safe, "context(__call_expr_arg_contexts)"}, {safe, "left_right(^[(,\\[]$,^[),\\]]$)"}, {safe, "context(skip_to(__expr_non_syntactic_contexts, stmt_child(node(array_subscript_expr), subscript)))"}, {safe, "context(skip_to(__expr_non_syntactic_contexts, stmt_child(operator(assign), lhs)))"}, -{safe, "context(skip_to(__expr_non_syntactic_contexts, stmt_child(node(init_list_expr||designated_init_expr), init)))"} +{safe, "context(skip_to(__expr_non_syntactic_contexts, stmt_child(node(init_list_expr||designated_init_expr), init)))"}, +{safe, "context(skip_to(__expr_non_syntactic_contexts, stmt_child(node(case_stmt), lower||upper)))"} -doc_end -doc_begin="Violations involving the __config_enabled macros cannot be fixed without diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index 36959aa44ac9..be2cc6bf03eb 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -376,7 +376,8 @@ Deviations related to MISRA C:2012 Rules: (2) as macro arguments; (3) as array indices; (4) as lhs in assignments; - (5) as initializers, possibly designated, in initalizer lists. + (5) as initializers, possibly designated, in initalizer lists; + (6) as constant expressions of switch case labels. - Tagged as `safe` for ECLAIR. * - R20.7