From: Yufeng Wang <[email protected]>
struct_size() expands to flex_array_size(), which uses __must_be_array()
to assert at build time that its argument is an array. __must_be_array()
is defined in the kernel's include/linux/compiler.h, but the tools/virtio
compiler.h compat shim does not provide it, so any use of struct_size()
in the test harness fails to build:
../include/linux/overflow.h:161:44: error: implicit declaration of function
'__must_be_array' [-Wimplicit-function-declaration]
161 | sizeof(*(p)->member) +
__must_be_array((p)->member),\
| ^~~~~~~~~~~~~~~
vhost_net_test.c:258:32: note: in expansion of macro 'struct_size'
Stub __must_be_array() to 0, consistent with how BUILD_BUG_ON() and
__must_check are already stubbed out in this environment.
Signed-off-by: Yufeng Wang <[email protected]>
---
tools/virtio/linux/compiler.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/virtio/linux/compiler.h b/tools/virtio/linux/compiler.h
index 0f25db473f55..3fa035296fab 100644
--- a/tools/virtio/linux/compiler.h
+++ b/tools/virtio/linux/compiler.h
@@ -40,5 +40,6 @@
})
#define __must_check
+#define __must_be_array(a) 0
#endif
--
2.34.1
No virus found
Checked by Hillstone Network AntiVirus