From patchwork Tue Sep 10 10:50:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13798323 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 25D8BECE564 for ; Tue, 10 Sep 2024 10:50:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.795383.1204735 (Exim 4.92) (envelope-from ) id 1snyRu-0005u7-9r; Tue, 10 Sep 2024 10:50:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 795383.1204735; Tue, 10 Sep 2024 10:50:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1snyRu-0005u0-6w; Tue, 10 Sep 2024 10:50:18 +0000 Received: by outflank-mailman (input) for mailman id 795383; Tue, 10 Sep 2024 10:50:17 +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 1snyRs-0005eE-VK for xen-devel@lists.xenproject.org; Tue, 10 Sep 2024 10:50:16 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 761832a1-6f62-11ef-a0b5-8be0dac302b0; Tue, 10 Sep 2024 12:50:15 +0200 (CEST) Received: from truciolo.homenet.telecomitalia.it (host-79-37-206-90.retail.telecomitalia.it [79.37.206.90]) by support.bugseng.com (Postfix) with ESMTPSA id 69CD44EE07BE; Tue, 10 Sep 2024 12:50:14 +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: 761832a1-6f62-11ef-a0b5-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1725965414; bh=aoNTUKoXfcXXjlXwKVUxj5UZJoOJwzKkIhTK6KbP6Pk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BQf4juL96tsmyJOZNAqdJ25r9X/6rUgt1kSKVnCkenztbeOExd6BnibvXrsJBINr7 G9YEgOIPrO3ATLt+bpjkykNfe+CYgHwg7xxsKjgRnhRoYEuaGTaiqtRqE4xgMKKxHS g1J7s3lBCMe5gjCdiuueDeZYviuA3KvQcyPF1hNHXY2iLB4cSNXOk8RVgk0FekMDiu HF8bM9zU5VssUX7w4rGf8NE3rd2p9T1lEFJKIZ3NYZMNHi3SSMIuHnaDLY16MqeaZs 0XyZnUjGU8JlcjjE9E8YZguvhzj6joVPW6chLl/RLEeH8KAfUGqZXm5spT5hcteE7x DgHFImGw5CuLw== From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Simone Ballarin , Doug Goldstein , Stefano Stabellini , Andrew Cooper , Jan Beulich , Julien Grall Subject: [XEN PATCH v2 1/2] automation/eclair: update configuration of Rule 20.7 Date: Tue, 10 Sep 2024 12:50:06 +0200 Message-Id: <2e77768c0f0e4c3cdae099201bcceca635158bf8.1725963889.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 MISRA C:2012 Rule 20.7 states that "Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses". The rational of the rule is that if a macro argument expands to an expression, there may be problems related to operator precedence, e.g., define M(A, B) A * B M(1+1, 2+2) will expand to: 1+1 * 2+2 Update ECLAIR configuration to tag as 'safe' the expansions of macro arguments surrounded tokens '{', '}' and ';', since in their presence problems related to operator precedence can not occur. Signed-off-by: Federico Serafini Acked-by: Stefano Stabellini --- Changes from v1: - more details to justify the deviation; - split modifications in two patches. --- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ docs/misra/deviations.rst | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index 9051f41602..e0d9426b7a 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -581,6 +581,10 @@ of this macro do not lead to developer confusion, and can thus be deviated." -config=MC3R1.R20.7,reports+={safe, "any_area(any_loc(any_exp(macro(^count_args_$))))"} -doc_end +-doc_begin="Problems related to operator precedence can not occur if the expansion of the macro argument is surrounded by tokens '{', '}' and ';'." +-config=MC3R1.R20.7,expansion_context+={safe, "left_right(^[\\{;]$,^[;\\}]$)"} +-doc_end + -doc_begin="Uses of variadic macros that have one of their arguments defined 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 and diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index b66c271c4e..69f93a6a91 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -534,6 +534,11 @@ Deviations related to MISRA C:2012 Rules: refactoring it to add parentheses breaks its functionality. - Tagged as `safe` for ECLAIR. + * - R20.7 + - Problems related to operator precedence can not occur if the expansion + of the macro argument is surrounded by tokens '{', '}' and ';'. + - Tagged as `safe` for ECLAIR. + * - R20.12 - Variadic macros that use token pasting often employ the gcc extension `ext_paste_comma`, as detailed in `C-language-toolchain.rst`, which is From patchwork Tue Sep 10 10:50:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13798325 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 CEC6FECE58D for ; Tue, 10 Sep 2024 10:50:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.795384.1204739 (Exim 4.92) (envelope-from ) id 1snyRu-0005yY-Il; Tue, 10 Sep 2024 10:50:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 795384.1204739; Tue, 10 Sep 2024 10:50:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1snyRu-0005xo-E9; Tue, 10 Sep 2024 10:50:18 +0000 Received: by outflank-mailman (input) for mailman id 795384; Tue, 10 Sep 2024 10:50:17 +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 1snyRt-0005fZ-4q for xen-devel@lists.xenproject.org; Tue, 10 Sep 2024 10:50:17 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 762f38ed-6f62-11ef-99a1-01e77a169b0f; Tue, 10 Sep 2024 12:50:15 +0200 (CEST) Received: from truciolo.homenet.telecomitalia.it (host-79-37-206-90.retail.telecomitalia.it [79.37.206.90]) by support.bugseng.com (Postfix) with ESMTPSA id CFBBF4EE07C1; Tue, 10 Sep 2024 12:50:14 +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: 762f38ed-6f62-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1725965415; bh=0ZGnWAy4OCBAC2wBwOqDOV4lU1P+EdH3+Hv5w4eAI60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYSlSMBRn3Xrj7KrwDqipee9gy4NoJ8F1OswG+80DKPQnxvd9NwCzf+dpnkon5dqo 6XiviMgbpiYk4uaOHo+IleWkiI33Y9cbdZqpnpT7yJLKCaZ5dpaiTWpRUu1t9Ps0cL aE4shdjqNYENJN5qsju4f648BY5zPuT7kgq7DC8OMZZYHiJ10eOC58SCW39EVJRL16 +cr+V+ORsEzNJ0uuvqiRsKA6qP+qA26ltMU3j03bluMy/ATmdKZAtMm9JHVc0EFFEa gf0g22Vz38FqJzKoepMUDLi/Wej2Xg8ekPJdoCBaAxV1iU2IGhSJuooWwyAKBYZFa2 wlfuxDC6e+x/Q== From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations Date: Tue, 10 Sep 2024 12:50:07 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Remove comment-based deviations since a project wide deviation that cover such cases is present. Signed-off-by: Federico Serafini Acked-by: Stefano Stabellini --- Changes from v1: - split modifications in two patches. --- xen/include/xen/bitmap.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h index 5d668053b0..4b642cd420 100644 --- a/xen/include/xen/bitmap.h +++ b/xen/include/xen/bitmap.h @@ -103,13 +103,10 @@ extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order); #define bitmap_switch(nbits, zero, small, large) \ unsigned int n__ = (nbits); \ if (__builtin_constant_p(nbits) && !n__) { \ - /* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \ zero; \ } else if (__builtin_constant_p(nbits) && n__ <= BITS_PER_LONG) { \ - /* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \ small; \ } else { \ - /* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \ large; \ }