From: Manish Honap C does not permit initialiser expressions on variable-length arrays. vfio_pci_irq_set() declared u8 buf[sizeof(struct vfio_irq_set) + sizeof(int) * count] = {}; where count is a function parameter, making buf a VLA. GCC rejects this with "variable-sized object may not be initialized". Replace the initialiser with an explicit memset() immediately after the declaration. Fixes: 19faf6fd969c2 ("vfio: selftests: Add a helper library for VFIO selftests") Signed-off-by: Manish Honap --- tools/testing/selftests/vfio/lib/vfio_pci_device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_device.c b/tools/testing/selftests/vfio/lib/vfio_pci_device.c index fac4c0ecadef..3258e814f450 100644 --- a/tools/testing/selftests/vfio/lib/vfio_pci_device.c +++ b/tools/testing/selftests/vfio/lib/vfio_pci_device.c @@ -26,8 +26,10 @@ static void vfio_pci_irq_set(struct vfio_pci_device *device, u32 index, u32 vector, u32 count, int *fds) { - u8 buf[sizeof(struct vfio_irq_set) + sizeof(int) * count] = {}; + u8 buf[sizeof(struct vfio_irq_set) + sizeof(int) * count]; struct vfio_irq_set *irq = (void *)&buf; + + memset(buf, 0, sizeof(buf)); int *irq_fds = (void *)&irq->data; irq->argsz = sizeof(buf); -- 2.25.1