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

Re: [PATCH 3/8] gnttab: Remove unused-but-set variable


  • To: Michal Orzel <michal.orzel@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 28 Apr 2022 09:27:16 +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=nmlaLJ6caXKxLsGhAN3oS612Sc6Dfi4O4FgH/hA9zDI=; b=fpo8HdZxW5cYNeLK82X8WNcTLn9mOQcX0Eo/P9nORLGxaoFVY8uEVUsiwCjHbh3SV0F/WwXJLWu81wRi/9XMx57u+QgYu9RELLoxaWjO8KClyi2hqQx0uy23t/E/WGrMoiVR6lSSaSwPdjdbtOBergCYqhKNxeepkoLgBBvjBXENpRN0oH/ctYjTMVs+idB6bnL/aWUqCcWCv+nDZo5cZAbDMaDEo13/LBcRwVQVRpo34jP6k5gaA6oUdN998fZGX4zOrSijXsMhLYped1m5UFFA6xPeSS1hCAj9AD7tR9gtM8Dm9Aq0J42iJdGScuuFoA/cDsd9jAoH8iNkG4iovw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMzw7vtvaotWaIwLikmDifKz63xK8l2raMmThnUd3j/G5SJw26qmDqJvggVBQqm7Rs2upfDEjroDwZHAS83/SSxdTGf0/zYKzV4+LOaOwU8yxEFuxvNzB5kearrRCSWzGNFD/EaW/J8UpZ0F6CJrPL19lQ7JNTZ892R0WzbALfExs0HwP8fj+8hD3FwD1cljzU9Czvr3m2XXHaBcB8MysutyOl2/uqbcSPKawEuFSPsIxZTIO1cYzbx8nYEij0ocvGkv2/xbT3xtsA5e8JN91k0TzxmqAK3L2WiovusdEEsRFabZ6YuDiugGw9qIizQwUp6JoDRMzPrly0HHbNsk2Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 28 Apr 2022 07:27:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 28.04.2022 09:16, Michal Orzel wrote:
> Hi Andrew, Jan
> 
> On 27.04.2022 14:33, Andrew Cooper wrote:
>> On 27/04/2022 12:06, Michal Orzel wrote:
>>> Hi Jan,
>>>
>>> On 27.04.2022 11:59, Jan Beulich wrote:
>>>> On 27.04.2022 11:49, Michal Orzel wrote:
>>>>> Function unmap_common_complete defines and sets a variable ld that is
>>>>> later on passed to a macro gnttab_host_mapping_get_page_type. On arm
>>>>> this macro does not make use of any arguments causing a compiler to
>>>>> warn about unused-but-set variable (when -Wunused-but-set-variable is
>>>>> enabled). Fix this by removing ld and directly passing current->domain
>>>>> to gnttab_host_mapping_get_page_type.
>>>> I think we want to retain the ld / rd notation. Therefore I think it's
>>>> rather the Arm macro which wants adjusting to not leave this argument
>>>> unused.
>>>>
>>> I would agree provided that the ld variable was used in more than one place.
>>> As it is not, it does not seem very beneficial to keep a variable that is 
>>> used
>>> just in one place and stores the macro value.
>>>
>>> When it comes to gnttab_host_mapping_get_page_type macro, on Arm it is 
>>> defined as (0)
>>> so modifying it seems to be a quite big overhead.
>>
>> diff --git a/xen/arch/arm/include/asm/grant_table.h
>> b/xen/arch/arm/include/asm/grant_table.h
>> index d31a4d6805d6..9f68c2a37eb6 100644
>> --- a/xen/arch/arm/include/asm/grant_table.h
>> +++ b/xen/arch/arm/include/asm/grant_table.h
>> @@ -31,10 +31,10 @@ static inline void gnttab_mark_dirty(struct domain
>> *d, mfn_t mfn)
>>  
>>  int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
>>                                unsigned int flags, unsigned int
>> cache_flags);
>> -#define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
>> +#define gnttab_host_mapping_get_page_type(ro, ld, rd) (ro, ld, rd, 0)
>>  int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
>>                                 unsigned long new_gpaddr, unsigned int
>> flags);
>> -#define gnttab_release_host_mappings(domain) 1
>> +#define gnttab_release_host_mappings(domain) (domain, 1)
>>  
>>  /*
>>   * The region used by Xen on the memory will never be mapped in DOM0
>>
>> It's about parameter evaluation, not about adding extra code when compiled.
>>
> 
> Unfortunately, solution presented by Andrew does not work.
> We will get the following error due to -Werror=unused-value:
> "left-hand operand of comma expression has no effect"

Perhaps

#define gnttab_host_mapping_get_page_type(ro, ld, rd) \
    ((void)(ro), (void)(ld), (void)(rd), 0)

?

Jan




 


Rackspace

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