[PATCH 3/3] virtio-pci: Use cpumask_available to fix compilation error
From: Christophe de Dinechin
Date: Thu Apr 14 2022 - 11:46:24 EST
With GCC 12 and defconfig, we get the following error:
| CC drivers/virtio/virtio_pci_common.o
| drivers/virtio/virtio_pci_common.c: In function ‘vp_del_vqs’:
| drivers/virtio/virtio_pci_common.c:257:29: error: the comparison will
| always evaluate as ‘true’ for the pointer operand in
| ‘vp_dev->msix_affinity_masks + (sizetype)((long unsigned int)i * 8)’
| must not be NULL [-Werror=address]
| 257 | if (vp_dev->msix_affinity_masks[i])
| | ^~~~~~
This happens in the case where CONFIG_CPUMASK_OFFSTACK is not defined,
since we typedef cpumask_var_t as an array. The compiler is essentially
complaining that an array pointer cannot be NULL. This is not a very
important warning, but there is a function called cpumask_available that
seems to be defined just for that case, so the fix is easy.
Signed-off-by: Christophe de Dinechin <christophe@xxxxxxxxxxxx>
Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>
---
drivers/virtio/virtio_pci_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index d724f676608b..5c44a2f13c93 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -254,7 +254,7 @@ void vp_del_vqs(struct virtio_device *vdev)
if (vp_dev->msix_affinity_masks) {
for (i = 0; i < vp_dev->msix_vectors; i++)
- if (vp_dev->msix_affinity_masks[i])
+ if (cpumask_available(vp_dev->msix_affinity_masks[i]))
free_cpumask_var(vp_dev->msix_affinity_masks[i]);
}
--
2.35.1