[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 26 Oct 2023 14:39:12 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mW/rpsuDDMfLZC1kac+VgtyspHC0JL2PsRIaddtjRYQ=; b=FZoKMs0UWlW3u+UWDg/DJlGQS7GH1L8nl1+UUjE1a2798TVwK9UkqMWKg8hZHhLOxFFACXwHbSrvOF/QmUu9vzTTDGCri+WOmjMfxIxmMB4wk2BaVzRif+XL9/9TeV30962nGRbqwlcQ6lH39TL1mzueC18bI9Rs7OV+sY2OHB+Ru0IGlzseLiuP4SRA0W3Dyzt1+1YpR+RdsiD9+wvhBlWAq0ClWt5FUg6XDdjFrb8jK+ed3x0LfT9ItYh8mYnUbhn6vHgaWlNUMawxmE87w+R6i8Va9sVFuN/5dRvoeIfBeqFPgknZcCWQY9s7oY7Uy4aHN6RE0b4sjFXS5f9J4Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ThYDUZ6nislAfKqu8FinskBEYpVkysYLk+dNvx7zlKKHSGQhbleKt6noTA0933SFTtguoGPP+fGLVtgplzYPBhu37nOzaSbJAvKAGdNnYnrzec5405IB7Civmnfv1rxAyjypbBntAiJmPsEf+Lmo9oIPglfQl3/fxuJIu5eJYNgdJvQd3yJw35HzTeT86lVSLtjwWyuc+Obk1EgwLsr9Gaio0hdOJ/J1c6cybAcdOUUMIhtTLl4LZ4kcx+i489Fg0guhADXvwf8XAE4Z0mmqtz/gG1C2jNep0RSpcQ9gjQMv7+hPB7SI/bHzwBDyMaILutKisQjpXjRlyxsxxAYWFA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 26 Oct 2023 12:39:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.10.2023 14:32, Nicola Vetrini wrote:
> 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 <nicola.vetrini@xxxxxxxxxxx>
>>>>
>>>> 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.
> 
> 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}
>           },

Adding a dependency on the array actually having 4 elements (while iirc
we have seen already that we could in principle go down to 3). A change
of this number would then require touching all these sites, which is
what we'd like to avoid.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.