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 56485C25B67 for ; Thu, 26 Oct 2023 12:32:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.623781.971949 (Exim 4.92) (envelope-from ) id 1qvzWw-0001R4-2M; Thu, 26 Oct 2023 12:32:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 623781.971949; Thu, 26 Oct 2023 12:32:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qvzWv-0001Qx-Vw; Thu, 26 Oct 2023 12:32:05 +0000 Received: by outflank-mailman (input) for mailman id 623781; Thu, 26 Oct 2023 12:32:04 +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 1qvzWu-0001PT-3p for xen-devel@lists.xenproject.org; Thu, 26 Oct 2023 12:32:04 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id aa8eb622-73fb-11ee-98d5-6d05b1d4d9a1; Thu, 26 Oct 2023 14:32:03 +0200 (CEST) Received: from support.bugseng.com (support.bugseng.com [162.55.131.47]) by support.bugseng.com (Postfix) with ESMTPA id BA2784EE0742; Thu, 26 Oct 2023 14:32:02 +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: aa8eb622-73fb-11ee-98d5-6d05b1d4d9a1 MIME-Version: 1.0 Date: Thu, 26 Oct 2023 14:32:02 +0200 From: Nicola Vetrini To: Jan Beulich Cc: Stefano Stabellini , michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, andrew.cooper3@citrix.com, roger.pau@citrix.com, Wei Liu , xen-devel@lists.xenproject.org Subject: Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3 In-Reply-To: <41562c7a-6260-3104-b2d4-d6fd4df0cffc@suse.com> References: <76c9f78179a8bb5b4f99b34f163933394f79066c.1698155925.git.nicola.vetrini@bugseng.com> <60e26ad6-7366-2604-e9b2-ed401cee6e73@suse.com> <41562c7a-6260-3104-b2d4-d6fd4df0cffc@suse.com> User-Agent: Roundcube Webmail/1.4.3 Message-ID: <4e88d7ab94b9fc73554eee5b78612b63@bugseng.com> X-Sender: nicola.vetrini@bugseng.com Organization: BUGSENG s.r.l. Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit On 25/10/2023 09:56, Jan Beulich wrote: > On 24.10.2023 22:27, Stefano Stabellini wrote: >> On Tue, 24 Oct 2023, Jan Beulich wrote: >>> On 24.10.2023 16:31, Nicola Vetrini wrote: >>>> Partially explicitly initalized .matches arrays result in violations >>>> of Rule 9.3; this is resolved by using designated initializers, >>>> which is permitted by the Rule. >>>> >>>> Mechanical changes. >>>> >>>> Signed-off-by: Nicola Vetrini >>> >>> While not overly bad, I'm still not really seeing the improvement. >>> Yet aiui changes induced by Misra are supposed to improve things in >>> some direction? >> >> I think the improvement is clarity, in the sense that the designated >> initializers make it clearer that the array may be sparsely >> initialized >> and that the remaining elements should be initialized to zero >> automatically. > > That's as clear from the original code, imo. > > Jan There's also this functionally equivalent alternative, with or without the zeros, which doesn't incur in the risk of mistakenly attempting to initialize the same element twice, while also giving an explicit cue to the reader that all elements are truly zero-initialized. .matches = { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + {0}, {0} }, -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)