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 4C2F0EB64DA for ; Tue, 18 Jul 2023 13:48:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.565285.883315 (Exim 4.92) (envelope-from ) id 1qLl3m-0005TN-Iz; Tue, 18 Jul 2023 13:48:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 565285.883315; Tue, 18 Jul 2023 13:48:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qLl3m-0005TG-Ff; Tue, 18 Jul 2023 13:48:14 +0000 Received: by outflank-mailman (input) for mailman id 565285; Tue, 18 Jul 2023 13:48:13 +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 1qLl3l-0005TA-O1 for xen-devel@lists.xenproject.org; Tue, 18 Jul 2023 13:48:13 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bce056fc-2571-11ee-b23a-6b7b168915f2; Tue, 18 Jul 2023 15:48:12 +0200 (CEST) Received: from [192.168.1.100] (unknown [37.161.123.45]) by support.bugseng.com (Postfix) with ESMTPSA id C6C334EE0C88; Tue, 18 Jul 2023 15:48:10 +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: bce056fc-2571-11ee-b23a-6b7b168915f2 Message-ID: Date: Tue, 18 Jul 2023 15:48:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [RFC PATCH 2/4] xen/arm64: bitops: justify uninitialized variable inside a macro Content-Language: en-US To: Jan Beulich Cc: Xen-devel , Stefano Stabellini , "michal.orzel@amd.com" , "xenia.ragiadakou@amd.com" , "ayan.kumar.halder@amd.com" , "consulting@bugseng.com" , Andrew Cooper , George Dunlap , Julien Grall , Wei Liu , Bertrand Marquis , Volodymyr Babchuk , Luca Fancellu References: <3356b44e-a596-8cff-afd9-66bbcca53b30@bugseng.com> <996e3d7d-96db-2f3d-8f4e-0805a2c60a6f@suse.com> From: Nicola Vetrini In-Reply-To: <996e3d7d-96db-2f3d-8f4e-0805a2c60a6f@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 17/07/23 17:46, Jan Beulich wrote: > On 17.07.2023 17:28, Nicola Vetrini wrote: >> >> >> On 17/07/23 15:59, Jan Beulich wrote: >>> On 14.07.2023 16:20, Luca Fancellu wrote: >>>> >>>> >>>>> On 14 Jul 2023, at 12:49, Nicola Vetrini wrote: >>>>> >>>>> The macro 'testop' expands to a function that declares the local >>>>> variable 'oldbit', which is written before being set, but is such a >>>>> way that is not amenable to automatic checking. >>>>> >>>>> Therefore, a deviation comment, is introduced to document this situation. >>>>> >>>>> A similar reasoning applies to macro 'guest_testop'. >>>>> >>>>> Signed-off-by: Nicola Vetrini >>>>> --- >>>>> docs/misra/safe.json | 16 ++++++++++++++++ >>>>> xen/arch/arm/arm64/lib/bitops.c | 3 +++ >>>>> xen/arch/arm/include/asm/guest_atomics.h | 3 +++ >>>>> 3 files changed, 22 insertions(+) >>>>> >>>>> diff --git a/docs/misra/safe.json b/docs/misra/safe.json >>>>> index 244001f5be..4cf7cbf57b 100644 >>>>> --- a/docs/misra/safe.json >>>>> +++ b/docs/misra/safe.json >>>>> @@ -20,6 +20,22 @@ >>>>> }, >>>>> { >>>>> "id": "SAF-2-safe", >>>>> + "analyser": { >>>>> + "eclair": "MC3R1.R9.1" >>>>> + }, >>>>> + "name": "Rule 9.1: initializer not needed", >>>>> + "text": "The following local variables are possibly subject to being read before being written, but code inspection ensured that the control flow in the construct where they appear ensures that no such event may happen." >>>>> + }, >>>>> + { >>>>> + "id": "SAF-3-safe", >>>>> + "analyser": { >>>>> + "eclair": "MC3R1.R9.1" >>>>> + }, >>>>> + "name": "Rule 9.1: initializer not needed", >>>>> + "text": "The following local variables are possibly subject to being read before being written, but code inspection ensured that the control flow in the construct where they appear ensures that no such event may happen." >>>>> + }, >>>> >>>> Since the rule and the justification are the same, you can declare only once and use the same tag on top of the offending lines, so /* SAF-2-safe MC3R1.R9.1 */, >>> >>> +1 >>> >>> I'm puzzled by the wording vs comment placement though: The comments >>> are inserted ahead of the macro invocations, so there are no "following >>> local variables". Plus does this imply the comment would suppress the >>> checking on _all_ of them, rather than just the one that was confirmed >>> to be safe? What if another new one was added, that actually introduces >>> a problem? >>> >>>> also, I remember some maintainers not happy about the misra rule being put after the tag, now I don’t recall who >>> >>> Me, at least. The annotations should be tool-agnostic imo, or else the >>> more tools we use, the longer these comments might get. >> >> No problem for both: Given the earlier remarks by Julien on patch 1/4, I >> think we can devise something along the lines of >> >> /* SAF-x-safe MISRA:C 2012 Rule 9.1 */ >> int var; >> >> and then write a generic justification in docs/misra/safe.json, while >> contains a specific one (e.g., this loop does so and so >> to ensure that no access to unset variables happens). > > But that still mentions the rule. What if a new MISRA:C 2025 appears, > with different rule numbers? I don't mind the comment mentioning, in > a sufficiently terse way, what problem is circumvented. But I don't > think tools or specifications should be referenced here. That's the > purpose of the referenced "database" entry. > > Jan Ok -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)