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

Re: [PATCH 2/2] xen/arm: Fix MISRA regression on R1.1, flexible array member not at the end


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Thu, 2 May 2024 06:33:12 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=W6FwU0Q3/gqWAiXf1Xgd8ehO2TYoveL/szN9rczxeDY=; b=M0t9jdZ/S5x/xivj1UXJlaob9fbMc0vP5ND7iGyBKyW3Z3yhgL35lqUYO2YvJd5d0vppvYRHfd80eTVeSFByIhsD6yDwCpEUDdmebQ31vzxGUB0NzAISfb9jJkmrVrVy3JgdHBjD7dzpqyWZ6fFkH2BQcvKKq8qaiLofjSGc6g4ewnWTOLWW6ufvvJQdemm/Yj8DGq8zFKFGl51QlFdrwWlXp7RRn1XoS/w4DmcB0d/1sD8vfIga/OtVTwbr2sF6goI3NWObgrNdJsxTlCU+SrJ8bZkE4tOjM8i9z/4h5CCEz2TBjRYV8NRvtuzIUxmopIgOBwu0kW/4b6YLThJdcg==
  • 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=W6FwU0Q3/gqWAiXf1Xgd8ehO2TYoveL/szN9rczxeDY=; b=KKvoOmKZNbU7aAA9LLYgh3nm1T+JbS7qrCvyOAPFnSj53KOZU2sRI8iekoftndGSsqZztWmCUKrTINjPyGCQ0xi/bsUVOCb33EGCr0fj7WDOtG8IdvwNb7NJp8DdlZ4CaVA1hmgcz2Oxjgv8207245KBbCOCjAgupMytSrmm80wU86VSs+SCQVAU79mWKL0FqlVg4nBcozts2x+5axb/b7AmX+qd8FBcoXsCfWUXKYd1pKzsAf1FmMFXidBa35WbIxQRIz6HgRciUvNZktksckEgRTM9oGFGjzGb1DIv7nRpcqZiEtGDJ9KEA52Dy7h7zZ0z2216cMhXUBDs6wyrSA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=D4lbCH20xwLmVm9/jrUKHO4M8dNC2VvXWC7VQkug9urURtDmYVIxbXb28PEkHdQKddKBJDNm4GjmTcPfjThJTJF+XFM1XQnZzKuvN3LCq2W6fl4ArKVxBL95i4UwS3FVQAUpegyguBDt7aNfMlMxw+AhBw/0BDexBwyCuNQ9FlWXGZWWW1T6GrN12xzAkuR7kCtKTHnPqAc4fAzQUSnvFlw4wqhlbf9OrNQE3C6HBjFWJQfa57Pghhe4PDpzYw7S2vDt/rk9zxOuqYhV5ADu8JVji4/eCnQ+2FQpol0DsoDwmwyleRJQgPGdXYCH2iI/hYgPxOcGJQZIViawqzWJDg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nQc2oVk9e9mQncIHU6jpw+vMkqqdj62r99B7NSA+37vMRZ+Cz6zdJRH8qspSwScZRKWyeZrE088aSZwlnBkoZV+zxljsErPbXPyn6uKzzN4wCrO1qpeIZuuyFKiwxqWw8B+8vVlAqODtVJmAYeHJ7HjusiXjJfwG5a7lBhRJM4HGNL03RmiD4gXVK0eKMSna/08uL5VHG7YNcm4ckuOWUmGUGDPPAsqgtHfMNMG6ffVcVRPiwLm3FU8aTWqcloOat1DJEgwszRGewy3q4iFj7PKxl2JD4TNf2PVQ5K/YsEM8cc4MsJaVnpVBBumOUvWCSFUE/6E7WV0C0lFwoInW1A==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "consulting @ bugseng . com" <consulting@xxxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 02 May 2024 06:33:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHamu72Eq1RpEGs60mNp9DIfY8mn7GAr6+AgAFEGQCAAYYzgIAABVAA
  • Thread-topic: [PATCH 2/2] xen/arm: Fix MISRA regression on R1.1, flexible array member not at the end


> On 2 May 2024, at 07:14, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 01.05.2024 08:57, Luca Fancellu wrote:
>> Hi Jan,
>> 
>>> On 30 Apr 2024, at 12:37, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>> 
>>> On 30.04.2024 13:09, Luca Fancellu wrote:
>>>> --- a/xen/arch/arm/include/asm/setup.h
>>>> +++ b/xen/arch/arm/include/asm/setup.h
>>>> @@ -64,18 +64,20 @@ struct membank {
>>>> };
>>>> 
>>>> struct membanks {
>>>> -    unsigned int nr_banks;
>>>> -    unsigned int max_banks;
>>>> +    __struct_group(membanks_hdr, common, ,
>>>> +        unsigned int nr_banks;
>>>> +        unsigned int max_banks;
>>>> +    );
>>>>    struct membank bank[];
>>>> };
>>> 
>>> I'm afraid I can't spot why __struct_group() is needed here. Why would just
>>> one of the two more straightforward
>>> 
>>> struct membanks {
>>>   struct membanks_hdr {
>>>       unsigned int nr_banks;
>>>       unsigned int max_banks;
>>>   );
>>>   struct membank bank[];
>>> };
>>> 
>> 
>> At the first sight I thought this solution could have worked, however GCC 
>> brought me back down to earth
>> remembering me that flexible array members can’t be left alone in an empty 
>> structure:
>> 
>> /data_sdc/lucfan01/gitlab_mickledore_xen/xen/xen/arch/arm/include/asm/setup.h:70:6:
>>  error: declaration does not declare anything [-Werror]
>> 70 | };
>> | ^
>> /data_sdc/lucfan01/gitlab_mickledore_xen/xen/xen/arch/arm/include/asm/setup.h:71:20:
>>  error: flexible array member in a struct with no named members
>> 71 | struct membank bank[];
>> | ^~~~
>> [...]
> 
> Since for patch 1 you looked at Linux'es uapi/linux/stddef.h, the solution
> to this lies there, in __DECLARE_FLEX_ARRAY(). Alongside or instead of
> borrowing __struct_group(), we could consider borrowing this as well. Or
> open-code it just here, for the time being (perhaps my preference). Yet
> it's not clear to me that doing so will actually be enough to make things
> work for you.

I looked also into __DECLARE_FLEX_ARRAY(), but then decided __struct_group()
was enough for my purpose, can I ask the technical reasons why it would be your
preference? Is there something in that construct that is a concern for you?



 


Rackspace

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