Skip to content

Commit 0b4a709

Browse files
committed
vhost: fix clang build warning
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: ClangBuiltLinux/linux#508 Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Tested-by: Nathan Chancellor <[email protected]>
1 parent 7f46603 commit 0b4a709

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/vhost/vhost.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ struct vhost_uaddr {
9595
bool write;
9696
};
9797

98-
#define VHOST_ARCH_CAN_ACCEL_UACCESS defined(CONFIG_MMU_NOTIFIER) && \
99-
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 0
98+
#if defined(CONFIG_MMU_NOTIFIER) && ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 0
99+
#define VHOST_ARCH_CAN_ACCEL_UACCESS 1
100+
#else
101+
#define VHOST_ARCH_CAN_ACCEL_UACCESS 0
102+
#endif
100103

101104
/* The virtqueue structure describes a queue attached to a device. */
102105
struct vhost_virtqueue {

0 commit comments

Comments
 (0)