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

Re: [PATCH 1/6] arm/mpu: Find MPU region by range


  • To: Hari Limaye <Hari.Limaye@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Mon, 30 Jun 2025 14:10:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IlzqaeUyAWy5W3cUW9IzyPn7WSKQaGXp3YwzvABgZjE=; b=DslfOJ2LdwD8AUC/hxK76uRH3maBUFtycCY0Ik2At5cpPtkERHykG/xhMAX2w9qmNsfVibRx9uQCK/afrMyx6T4sTtv04VFjbvzbpbMfm+SoDscSpKwlwPRGzegDlbKNwUI0pG1vRmuJjjMW3gAc0b/UtqKb0UEgIzKdCfVfNGyfp/GYjlTcJ5zM1JiAjaFFrqgQWDBqsdFJAbtQt83XnwBZdfH2G8vbZVmpi+Osbmhr9xiLYg+R1hDfTuWxfmA0U0aanoLgBxp/uNUUFbndvObxTLdcSK8pFmybaA3qRhfQMSlZ7WrfAZXusgj/XzRmdmKWXk1FBwe0z4ctjXxxFA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O+iMugCrjj/4pIzva11912GB3RgRgI3eWR1k7BQmmc8g4gvHHk2lx2EWUB9z61mceON7yX0h+9kRgmbmbbPdze/qhpP7KauJS+4akvxDuEx7wLAZOKws2lzY4dllSDZcCyYAIYS8H/gmv1Vn8O+Ny7ULNWqZMY6BdXjljL6gf0YSZflVUVo8uj04L1uKPA4b7HDhpj473PvtUP5Ew/LN3g5DYRJvN4VgltMhuFbSYUhL9ocQsF+T0cRyMCXaKXHasnGdC9Tkk0Li44vcRnPmV4RoKhMnJse4EqiLQDREGYCY2ZTc/dNJZDFRHkke0jEVuAnC6I9/7C2eLnxUTpwaqQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Luca Fancellu <Luca.Fancellu@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 30 Jun 2025 12:10:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 30/06/2025 13:45, Hari Limaye wrote:
> Hi Michal,
> 
>  
> 
> Thank you very much for the review.
> 
>  
> 
> I just had a small clarification regarding the following comment:
> 
>>> +
> 
>> +    /* Allow index to be NULL */
> 
>> +    index = index ? index : &_index;
> 
>>If index argument is NULL, why bother setting this internal variable _index?
> 
>  
> 
> This assignment is intended to support `index` as an optional output 
> parameter:
> callers can pass NULL if they only care about the return value. This approach
> avoids repeated `if (index)` checks by aliasing to a local dummy variable 
> upfront.
You don't need multiple if ( index ). Just one at the end of a function by
modifying it to use goto e.g.:

rc = <return_code>;
goto out;

 out:
 if ( index )
        *index = i;

> 
> Would you be happy for me to retain this pattern, renaming the dummy variable 
> to
> make it clearer, e.g.:
> 
> ```
> 
> uint8_t dummy_index;
> 
> index = index ? index : &dummy_index;
> 
> ```
> 
> I would also update the documentation to clarify that index is optional.
This does not address my point about having and setting a variable that may not
be used.
> 
>  
> 
> Alternatively, if you’d prefer to disallow NULL for index and require the 
> caller
> to always provide a valid pointer, I’m happy to change it accordingly.
No, that's not what I had in mind. That said it's up to you to decide how you
want the caller to behave. If you think that obtaining index is not necessary in
all the scenarios, then you should retain your current functionality.

~Michal




 


Rackspace

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