[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/2] Arm32: tidy the memset() macro
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |