[PATCH 2/3] tools/virtio: add __must_be_array stub

From
rom.wang <hidden>
Date
2026-08-04 08:01:53
Also in
kvm, lkml, netdev
Reply to
rom.wang, 2026-08-04
From: Yufeng Wang <redacted>

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 <redacted>
---
 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
Thread (7 messages) 7 messages, 2 authors, last reply 2026-08-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help