From nobody Thu Nov 21 15:07:54 2024 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; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=bugseng.com ARC-Seal: i=1; a=rsa-sha256; t=1725802122; cv=none; d=zohomail.com; s=zohoarc; b=ZOJB3ZZDF+wS9l92OLE6N7KC7EDZecmbLweWAmpdvNR0NyyB5mJ6/H4eH8ctyPCFVXILyQEOevz+PFv927zaR+lR2/vCYRwmc0JaY8qUBHJG5y2TZKvHpTIq+oo9U6LXuXYqxu38Oe1mThT8CfczfxndrRMlfRi0HNLGJ4IVN58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725802122; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fwv+JjDx5EjTKOKFkKCPL0AIwEdQfSSOGqW/nvDwxLM=; b=SViw06oUDN+Z077jm7acitqZNpY8G35JJf2hdJG9TGuNQjkbsKmSVFMMmQQ5ppiUUEa1z2X+e7j5rz9ooVrtWPiu/ASc3c3mTlWCYjX/cnQbrrmf57N0Ofs5rCiPZA++flAqBLNLPL4/btBygDYy0/njno2bQsKnRL+8OQaLQtw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1725802121746430.3527902359988; Sun, 8 Sep 2024 06:28:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.792569.1202466 (Exim 4.92) (envelope-from ) id 1snHxX-0008Ed-QD; Sun, 08 Sep 2024 13:28:07 +0000 Received: by outflank-mailman (output) from mailman id 792569.1202466; Sun, 08 Sep 2024 13:28:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1snHxX-0008EW-N0; Sun, 08 Sep 2024 13:28:07 +0000 Received: by outflank-mailman (input) for mailman id 792569; Sun, 08 Sep 2024 13:28:07 +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 1snHxW-0008EQ-Ut for xen-devel@lists.xenproject.org; Sun, 08 Sep 2024 13:28:07 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2cfca11b-6de6-11ef-a0b4-8be0dac302b0; Sun, 08 Sep 2024 15:28:05 +0200 (CEST) Received: from nico.bugseng.com (unknown [46.228.253.214]) by support.bugseng.com (Postfix) with ESMTPSA id 4F3644EE074D; Sun, 8 Sep 2024 15:28:01 +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: 2cfca11b-6de6-11ef-a0b4-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1725802083; bh=5Gr9rdc3F6zX9bETFlIzyDdhSTLrhJwc5aFWP/EIt3E=; h=From:To:Cc:Subject:Date:From; b=cnoGPBv57xv6BOxqypqJdFc5GHE8MySvumu4MXI07xhAm+mciAdGmkJTCZbPJlasD EqeUbUl8d1dUrI6LjZrhuxs1Ku/a4ywioemdqnGsmZ/CPtcQYDF+lKK1+5oB6YeWbe SZpRbdt05AnEBwPC335oGJ/ko2FSNEfuvKzDIXjaX2Q0Of5N46nHdMxcKsIK3pmr+Q rTy2NCHdMSYGEs/GP+1HGuXRjz0CiI8IQR8WQF1mUaDeXSKRb8Dvjrg5zYW8I6h98P nOm6ZEAN+MyDRF5ZbMYl2ibvZidQ+89852GXEeQIp97yv7ea6FuSNeGyCu5oxGcHVP BUEMFDRzcXjLg== 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 , Jan Beulich , Julien Grall Subject: [XEN PATCH] automation/eclair_analysis: fix MISRA Rule 20.7 regression in self-tests.h Date: Sun, 8 Sep 2024 15:27:57 +0200 Message-ID: <4e59a8b7d97f34a824922013ffe5e44f70e6abaf.1725801931.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @bugseng.com) X-ZM-MESSAGEID: 1725802124411116600 Content-Type: text/plain; charset="utf-8" Prior to bd1664db7b7d ("xen/bitops: Introduce a multiple_bits_set() helper") the definition of {COMPILE,RUNTIME}_CHECK was fully compliant with respect to MISRA C Rule 20.7: "Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses." However, to allow testing function-like macros, parentheses on the "fn" parameter were removed and thus new violations of the rule have been introduced. Given the usefulness of this functionality, it is deemed ok to deviate these two macros for this rule, because their scope of (direct) usage is limited to just the file where they are defined, and the possibility of misuses is unlikely. No functional change. Fixes: bd1664db7b7d ("xen/bitops: Introduce a multiple_bits_set() helper") Signed-off-by: Nicola Vetrini Acked-by: Andrew Cooper Acked-by: Stefano Stabellini --- automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++ docs/misra/deviations.rst | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index 9051f4160282..ed80ac795851 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -581,6 +581,12 @@ of this macro do not lead to developer confusion, and = can thus be deviated." -config=3DMC3R1.R20.7,reports+=3D{safe, "any_area(any_loc(any_exp(macro(^c= ount_args_$))))"} -doc_end +-doc_begin=3D"The argument \"fn\" in macros {COMPILE,RUNTIME}_CHECK is not= parenthesized +on purpose, to be able to test function-like macros. Given the specialized= and limited +use of this macro, it is deemed ok to deviate them." +-config=3DMC3R1.R20.7,reports+=3D{deliberate, "any_area(any_loc(any_exp(ma= cro(^(COMPILE_CHECK|RUNTIME_CHECK)$))))"} +-doc_end + -doc_begin=3D"Uses of variadic macros that have one of their arguments def= ined as a macro and used within the body for both ordinary parameter expansion and= as an operand to the # or ## operators have a behavior that is well-understood a= nd diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index b66c271c4e7c..b020144a3254 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -533,6 +533,14 @@ Deviations related to MISRA C:2012 Rules: to incur in the risk of being misused or lead to developer confusio= n, and refactoring it to add parentheses breaks its functionality. - Tagged as `safe` for ECLAIR. + + * - R20.7 + - The macros `{COMPILE,RUNTIME}_CHECK` defined in + `xen/include/xen/self-tests.h` are allowed not to parenthesize their + arguments, to allow function-like macros to be tested as well as + functions. Given the specialized use of these macros and their limi= ted + usage scope, omitting parentheses is deemed unlikely to cause issue= s. + - Tagged as `deliberate` for ECLAIR. * - R20.12 - Variadic macros that use token pasting often employ the gcc extensi= on -- 2.43.0