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

Re: [PATCH 2/2] Arm32: tidy the memset() macro


  • To: Wei Chen <Wei.Chen@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 19 Aug 2022 14:39:38 +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=Ur+7GJqhe6YFw7xQ5XmBUTfifrq/LWJ6ea1rnL8x85Q=; b=Af7RSbkp1O9oVhIPQm8L6BOXnfzvWxnawrZFFt6EUmkQDKu+EwtNzQyZtz9kMU2WZExfCBv1jTpMrpQ/90xbLt0wqwLa3uWMqqZugBs5J7SKygrvpS+VisPMg7XyW+WYFpzHAD2/dHjUXingMS+/XC9uXXA0Z9WVes8UL3xGCu059MgceeWo7JdywAIne69a0DvH4E1b+ryoWs4ijQs+1foCS1PExLS9/GBtvGUjSg31GMCbk8t2+tgTFfiQ+bD12qxk8cqZTbTtQDGw+m4GqFb0dW6BYxhz6e2v/gasHQhjpDdYHgpTpaL+0xB/VPULqY8oNznDQ4iAe4EbHLElZw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MFANdjWGdWVBK04ZnDb2HHJtNrqyjoegC2VrazWzytJV1lWqE/WzfH9FY+10Q0CFE3pihF/7QXAh9uxdEnKNuAY8JeOab0otl3LVywCXKAkmzj20jibbx7L+TsOAc3Z55esUgN367ih/iPIx+I9LhWe4I1HtksqiGJVdjsBFSp8Vk/5w5M/6SKUuY463fHF146p4QCJr67A/HJB3s0EXQgkYQxtXBo75SFtQ0wrE6xwn7zWk3F6sv5IoLbxe/svfsyRJMHDF85DvX9eqBHOyMLMRcbm9ohWgD8mfAuxW09rHtCCfK9BgmVTqNXJWe0H/5o7Fh3JBRP8UvTWqAXWwGA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 19 Aug 2022 12:39:50 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 19.08.2022 11:41, Wei Chen wrote:
> Hi Jan,
> 
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@xxxxxxxx>
>> Sent: 2022年8月19日 16:04
>> To: Wei Chen <Wei.Chen@xxxxxxx>
>> Cc: Julien Grall <julien@xxxxxxx>; Stefano Stabellini
>> <sstabellini@xxxxxxxxxx>; Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>;
>> Bertrand Marquis <Bertrand.Marquis@xxxxxxx>; xen-
>> devel@xxxxxxxxxxxxxxxxxxxx
>> Subject: Re: [PATCH 2/2] Arm32: tidy the memset() macro
>>
>> On 19.08.2022 09:59, Wei Chen wrote:
>>>> -----Original Message-----
>>>> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of
>> Jan
>>>> Beulich
>>>> Sent: 2022年8月19日 15:50
>>>>
>>>> - add parentheses where they were missing (MISRA)
>>>> - make sure to evaluate also v exactly once (MISRA)
>>>> - remove excess parentheses
>>>> - rename local variables to not have leading underscores
>>>> - apply Xen coding style
>>>>
>>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>>> ---
>>>> I wonder whether "if ( n_ )" is really helpful: It's extra code in all
>>>> callers passing a non-constant size, just to cover a pretty rare case
>>>> which memset() is required to deal with correctly anyway, and which
>>>
>>> What rare case we need to use n_ that can make memset happy?
>>
>> I'm afraid I don't understand the question.
>>
> 
> Sorry I didn't describe the problem clearly in the last email. You mentioned
> whether if (n_) is useful in your patch comments. I looked at the 
> implementation
> of the current memset macro, and I didn't feel it was too useful.
> 
> Then in the comments you mentioned that if (n_) is just to cover a very rare 
> case.
> Does the rare case is memset(p, v, 0)?

Yes, albeit not in the form you've written it, but with the last argument
being a variable which happens to be zero. With literal zero, the compiler
would dead-code eliminate the construct anyway.

Jan

> If this is the case, I agree with you,
> memset itself should be able to handle with size=0.
> 
> Sorry again for confusing you!
> 
> Thanks,
> Wei Chen



 


Rackspace

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