x86/header: Use __DECLARE_FLEX_ARRAY() for struct setup_data flex array
PATCH 1/1 x86/header: Use __DECLARE_FLEX_ARRAY() for struct setup_data flex array
After the data member of struct setup_data was switched to a flex array by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members"), the struct can no longer be used as a header in a larger struct in C++, with errors like:
flexible array member ‘setup_data::data’ not at end of ‘struct ...’
This breaks compilation of our userspace code which imports the header in a C++ project.
Similar to commit 2619da73bb2f ("KVM: x86: Use __DECLARE_FLEX_ARRAY() for UAPI structures with VLAs"), declare the member with __DECLARE_FLEX_ARRAY(), which uses [0] for C++ compilation.
--- arch/x86/include/uapi/asm/setup_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/uapi/asm/setup_data.h +1 -1
@@ -28,7 +28,7 @@ struct setup_data {__u64 next;__u32 type;__u32 len; -__u8 data[]; +__DECLARE_FLEX_ARRAY (__u8, data); };/* extensible setup indirect data node */
Signature · 1 line
2.47.3
H. Peter Anvin
reviewerQuoted 23 lines · Federico Parola
After the
datamember of structsetup_datawas switched to a flex array by commit94dfc73e7cf4("treewide: uapi: Replace zero-length arrays with flexible-array members"), the struct can no longer be used as a header in a larger struct in C++, with errors like:
flexible array member ‘setup_data::data’ not at end of ‘struct ...’ This breaks compilation of our userspace code which imports the header in a C++ project.Similar to commit
2619da73bb2f("KVM: x86: Use__DECLARE_FLEX_ARRAY()for UAPI structures with VLAs"), declare the member with__DECLARE_FLEX_ARRAY(), which uses [0] for C++ compilation.Fixes 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members")Signed-off-by Federico Parola <[email protected]>---
arch/x86/include/uapi/asm/setup_data.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/uapi/asm/setup_data.h +0
-0
arch/x86/include/uapi/asm/setup_data.h struct setup_data { · line 34
Quoted 8 lines
arch/x86/include/uapi/asm/setup_data.h +1
-1@@ -28,7 +28,7 @@ struct setup_data {__u64 next;__u32 type;__u32 len; -__u8 data[]; +__DECLARE_FLEX_ARRAY (__u8, data); };/* extensible setup indirect data node */
Can we do this in the postprocessing of uapi headers, please?