vhost: silence an unused-variable warning
authorArnd Bergmann <arnd@arndb.de>
Wed, 6 Mar 2019 11:05:49 +0000 (12:05 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 6 Mar 2019 16:32:37 +0000 (11:32 -0500)
On some architectures, the MMU can be disabled, leading to access_ok()
becoming an empty macro that does not evaluate its size argument,
which in turn produces an unused-variable warning:

drivers/vhost/vhost.c:1191:9: error: unused variable 's' [-Werror,-Wunused-variable]
        size_t s = vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;

Mark the variable as __maybe_unused to shut up that warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c

index a2e5dc7716e21c7cbed163159a0c1262df977227..5ace833de74620bf1a089186057d766e7e3def63 100644 (file)
@@ -1188,7 +1188,7 @@ static bool vq_access_ok(struct vhost_virtqueue *vq, unsigned int num,
                         struct vring_used __user *used)
 
 {
-       size_t s = vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
+       size_t s __maybe_unused = vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
 
        return access_ok(desc, num * sizeof *desc) &&
               access_ok(avail,