Skip to content

Commit 3122cec

Browse files
committed
lib: virtio: Fix VIRTIO ROLE_XXXX macro definitions
Add parentheses around the "vdev" parameter to avoid side effects. This fixes a build error when using the macro in the following way: if (VIRTIO_ROLE_IS_DEVICE(&my_context->vdev)) The error encountered: openamp/open-amp/lib/include/openamp/virtio.h:89:49: error: invalid type argument of ‘->’ (have ‘struct virtio_device’) 89 | (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && (vdev->role) == VIRTIO_DEV_DRIVER) Signed-off-by: Arnaud Pouliquen <[email protected]>
1 parent bc1a7ef commit 3122cec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/include/openamp/virtio.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ extern "C" {
8686

8787
#ifdef VIRTIO_DRIVER_SUPPORT
8888
#define VIRTIO_ROLE_IS_DRIVER(vdev) \
89-
(VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && (vdev->role) == VIRTIO_DEV_DRIVER)
89+
(VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && ((vdev)->role) == VIRTIO_DEV_DRIVER)
9090
#else
9191
/* Default definition without code size optimization */
92-
#define VIRTIO_ROLE_IS_DRIVER(vdev) (vdev->role == VIRTIO_DEV_DRIVER)
92+
#define VIRTIO_ROLE_IS_DRIVER(vdev) ((vdev)->role == VIRTIO_DEV_DRIVER)
9393
#endif
9494

9595
#ifdef VIRTIO_DEVICE_SUPPORT
9696
#define VIRTIO_ROLE_IS_DEVICE(vdev) \
97-
(VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && (vdev->role) == VIRTIO_DEV_DEVICE)
97+
(VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && ((vdev)->role) == VIRTIO_DEV_DEVICE)
9898
#else
9999
/* Default definition without code size optimization */
100-
#define VIRTIO_ROLE_IS_DEVICE(vdev) (vdev->role == VIRTIO_DEV_DEVICE)
100+
#define VIRTIO_ROLE_IS_DEVICE(vdev) ((vdev)->role == VIRTIO_DEV_DEVICE)
101101
#endif
102102

103103
/** @brief Virtio device identifier. */

0 commit comments

Comments
 (0)