Skip to content

Commit

Permalink
vhost: fix clang build warning
Browse files Browse the repository at this point in the history
Clang warns:

  drivers/vhost/vhost.c:2085:5: warning: macro expansion producing
  'defined' has undefined behavior [-Wexpansion-to-defined]
  #if VHOST_ARCH_CAN_ACCEL_UACCESS
      ^
  drivers/vhost/vhost.h:98:38: note: expanded from macro
  'VHOST_ARCH_CAN_ACCEL_UACCESS'
  #define VHOST_ARCH_CAN_ACCEL_UACCESS defined(CONFIG_MMU_NOTIFIER) && \
                                       ^

It's being pedantic for the sake of portability, but the fix is easy
enough.

Rework the definition of VHOST_ARCH_CAN_ACCEL_UACCESS to expand to a constant.

Fixes: 7f46603 ("vhost: access vq metadata through kernel virtual address")
Link: https://github.com/ClangBuiltLinux/linux/issues/508
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
  • Loading branch information
Michael S. Tsirkin committed Jun 6, 2019
1 parent 7f46603 commit 0b4a709
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/vhost/vhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ struct vhost_uaddr {
bool write;
};

#define VHOST_ARCH_CAN_ACCEL_UACCESS defined(CONFIG_MMU_NOTIFIER) && \
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 0
#if defined(CONFIG_MMU_NOTIFIER) && ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 0
#define VHOST_ARCH_CAN_ACCEL_UACCESS 1
#else
#define VHOST_ARCH_CAN_ACCEL_UACCESS 0
#endif

/* The virtqueue structure describes a queue attached to a device. */
struct vhost_virtqueue {
Expand Down

0 comments on commit 0b4a709

Please sign in to comment.