On Tue, Aug 23, 2022 at 16:38:46 +0200, Michal Prívozník wrote: > On 8/23/22 16:15, Peter Krempa wrote: > > The most recent environment e.g. present in our Fedora Rawhide builds > > fail to build the tree with clang with the following error: > > > > ../src/util/virhostcpu.c:1291:25: error: field 'header' with variable sized type 'struct kvm_msrs' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] > > struct kvm_msrs header; > > ^ > > > > The problem seems to be that clang doesn't like the new way the > > 'entries' field in struct kvm_msrs is declared. > > > > To work around the issue we can simply allocate the variable dynamically > > and use the 'entries' member as it was intended to to access the > > members. > > > > Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> > > --- > > src/util/virhostcpu.c | 15 ++++++--------- > > 1 file changed, 6 insertions(+), 9 deletions(-) > > Yeah, since this code is heavily inspired by QEMU I wanted to wait a bit > to see how QEMU deals with this because allocating those few bytes > looked needless to me. But I guess there's no better solution. Anyway, This is a usual way how we deal with such structs e.g. in virNetDevGetEthtoolGFeatures. Additionally now it uses the intended accessor declared in 'struct kvm_msrs'. Also we have A LOT places where we allocate short temp strings just to format something. I'd not worry about overhead too much.