Re: [PATCH v2 15/15] KVM: Dynamically size memslot array based on number of used slots

Sean Christopherson
2019-10-22T15:22:24Z

On Tue, Oct 22, 2019 at 04:04:21PM +0200, Paolo Bonzini wrote:
> On 22/10/19 02:35, Sean Christopherson wrote:
> > + struct kvm_memory_slot memslots[];
> > + /*
> > + * WARNING: 'memslots' is dynamically-sized. It *MUST* be at the end.
> > + */
>
> Isn't that obvious from the flexible array member?

Probably. It's also unnecessary as the compiler (at least as of gcc 5.4)
will throw an error if it's not at the end. I think I even verified this
during development and still decided to leave the obnoxious warning in for
some reason...

include/linux/kvm_host.h:436:25: error: flexible array member not at end of struct
struct kvm_memory_slot memslots[];