Skip to content

Commit

Permalink
lib: virtio: fix zephyr build warning
Browse files Browse the repository at this point in the history
Building the samples/subsys/ipc/openamp_rsc_table/ sample generates the
following warning:

[24/182] Building C object zephyr/CMakeFiles/zephyr.dir/lib/open-amp/resource_table.c.obj
In file included from /zephyrproject/zephyr/lib/open-amp/./resource_table.h:11,
                 from /zephyrproject/zephyr/lib/open-amp/resource_table.c:30:
/zephyrproject/modules/lib/open-amp/open-amp/lib/include/openamp/virtio.h:83:2:
 warning: #warning "VIRTIO_DRIVER_SUPPORT and/or VIRTIO_DEVICE_SUPPORT should be defined" [-Wcpp]
   83 | #warning "VIRTIO_DRIVER_SUPPORT and/or VIRTIO_DEVICE_SUPPORT should be defined"
      |  ^~~~~~~

The issue occurs because the project includes the virtio API while
VIRTIO_DRIVER_SUPPORT and VIRTIO_DEVICE_SUPPORT is only defined for
the open-amp library build.

Fix the warning by testing deprecated usage of VIRTIO_DRIVER_ONLY and
VIRTIO_DEVICE_ONLY but not under
#if !defined(VIRTIO_DRIVER_SUPPORT) && !defined(VIRTIO_DEVICE_SUPPORT)
condition.

Signed-off-by: Arnaud Pouliquen <[email protected]>
  • Loading branch information
arnopo committed Jun 28, 2024
1 parent e9eef7c commit 04a4185
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/include/openamp/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,17 @@ extern "C" {
#define VIRTIO_DEV_DRIVER 0UL
#define VIRTIO_DEV_DEVICE 1UL

#if !defined(VIRTIO_DRIVER_SUPPORT) && !defined(VIRTIO_DEVICE_SUPPORT)
#ifdef VIRTIO_DRIVER_ONLY
#warning "VIRTIO_DRIVER_ONLY is deprecated, please use VIRTIO_DEVICE_SUPPORT=0"
#define VIRTIO_DRIVER_SUPPORT 1
#define VIRTIO_DEVICE_SUPPORT 0
#elif VIRTIO_DEVICE_ONLY
#endif /* VIRTIO_DRIVER_ONLY */

#ifdef VIRTIO_DEVICE_ONLY
#warning "VIRTIO_DEVICE_ONLY is deprecated, please use VIRTIO_DRIVER_SUPPORT=0"
#define VIRTIO_DRIVER_SUPPORT 0
#define VIRTIO_DEVICE_SUPPORT 1
#else
#warning "VIRTIO_DRIVER_SUPPORT and/or VIRTIO_DEVICE_SUPPORT should be defined"
#define VIRTIO_DRIVER_SUPPORT 1
#define VIRTIO_DEVICE_SUPPORT 1
#endif /* VIRTIO_DRIVER_ONLY */
#endif /*!defined(VIRTIO_DRIVER_SUPPORT) && !defined(VIRTIO_DEVICE_SUPPORT)*/
#endif /* VIRTIO_DEVICE_ONLY */

#define VIRTIO_ENABLED(option) (option == 1)

Expand Down

0 comments on commit 04a4185

Please sign in to comment.