>>> On 30.03.16 at 15:19, <paul.durr...@citrix.com> wrote:
>>  -----Original Message-----
>> From: Jan Beulich [mailto:jbeul...@suse.com]
>> Sent: 30 March 2016 14:17
>> To: Paul Durrant
>> Cc: Andrew Cooper; xen-de...@lists.xenproject.org; Keir (Xen.org)
>> Subject: RE: [PATCH] x86/hvm/viridian: zero and check vcpu context __pad
>> field
>> 
>> >>> On 30.03.16 at 13:26, <paul.durr...@citrix.com> wrote:
>> >> From: Jan Beulich [mailto:jbeul...@suse.com]
>> >> Sent: 30 March 2016 12:23
>> >> >>> On 30.03.16 at 12:32, <paul.durr...@citrix.com> wrote:
>> >> > --- a/xen/arch/x86/hvm/viridian.c
>> >> > +++ b/xen/arch/x86/hvm/viridian.c
>> >> > @@ -824,6 +824,8 @@ static int viridian_save_vcpu_ctxt(struct domain
>> *d,
>> >> hvm_domain_context_t *h)
>> >> >      for_each_vcpu( d, v ) {
>> >> >          struct hvm_viridian_vcpu_context ctxt;
>> >> >
>> >> > +        memset(&ctxt, 0, sizeof(ctxt));
>> >>
>> >> How about just adding an empty initializer to the declaration?
>> >>
>> >
>> > I think having a 'zero the entire struct' call at the start is better as it
>> > will cover any additions made to the struct in future. It's what I had
>> > mistakenly assumed was already there. In fact I think adding a similar call
>> > into the domain context save function would probably be worthwhile.
>> 
>> And how does the initializer approach not fulfill that intention?
>> 
> 
> Because any time anyone adds another field they have to remember to add 
> another initializer, which is what I forgot to do. This approach OTOH is 
> failsafe.

But note how I said "an empty initializer": When there is an
initializer at all, all fields not mentioned in the initializer will get
default initialized (i.e. zeroed). Hence an empty initializer
clears the entire structure.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to