History

KVM: Remove subtle "struct kvm_stats_desc" pseudo-overlay

Remove KVM's internal pseudo-overlay of kvm_stats_desc, which subtly aliases the flexible name[] in the uAPI definition with a fixed-size array of the same name. The unusual embedded structure results in compiler warnings due to -Wflex-array-member-not-at-end, and also necessitates an extra level of dereferencing in KVM. To avoid the "overlay", define the uAPI structure to have a fixed-size name when building for the kernel. Opportunistically clean up the indentation for the stats macros, and replace spaces with tabs. No functional change intended.

Sean Christopherson committed 11 months ago

Commit da142f31 parent 9ace47514 files · +70 −75Browse files

Showing the changes to include/uapi (1 of 14 files). Show all

Unified · Split

include/uapi/linux/kvm.h+8−0
@@ -14,6 +14,10 @@ · 13 unmodified lines
1414 #include <linux/ioctl.h>
1515 #include <asm/kvm.h>
1616
17+#ifdef __KERNEL__
18+#include <linux/kvm_types.h>
19+#endif
20+
1721 #define KVM_API_VERSION 12
1822
1923 /*
@@ -1579,7 +1583,11 @@ struct kvm_stats_desc { · 1559 unmodified lines
15791583 __u16 size;
15801584 __u32 offset;
15811585 __u32 bucket_size;
1586+#ifdef __KERNEL__
1587+ char name[KVM_STATS_NAME_SIZE];
1588+#else
15821589 char name[];
1590+#endif
15831591 };
15841592
15851593 #define KVM_GET_STATS_FD _IO(KVMIO, 0xce)