Skip to contentSkip to conversation

vhost: silence an unused-variable warning

PATCH In review Arnd Bergmann 4 participants 6 messages Mar 6, 2019 – Mar 9, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: silence an unused-variable warning

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.

---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
index a2e5dc7716e2..5ace833de746 100644
@@ -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,
Signature · 1 line
2.20.0
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Arnd Bergmann

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.

---
  drivers/vhost/vhost.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +0 -0
index a2e5dc7716e2..5ace833de746 100644

drivers/vhost/vhost.c static bool vq_access_ok(struct vhost_virtqueue *vq, unsigned int num, · line 1194

Quoted 8 lines
drivers/vhost/vhost.c +1 -1
@@ -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,
Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 19 lines · Arnd Bergmann

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.

---
  drivers/vhost/vhost.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +0 -0
index a2e5dc7716e2..5ace833de746 100644

drivers/vhost/vhost.c static bool vq_access_ok(struct vhost_virtqueue *vq, unsigned int num, · line 1194

Quoted 8 lines
drivers/vhost/vhost.c +1 -1
@@ -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,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#3 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Wed, 6 Mar 2019 12:05:49 +0100

Quoted 10 lines

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.

I'll apply this, thanks Arnd.

#4 lore raw
Quoted 7 lines · David Miller

From: Arnd Bergmann <[email protected]>
Date: Wed, 6 Mar 2019 12:05:49 +0100

Quoted 4 lines

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:

Quoted 8 lines
Quoted 6 lines

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.

I'll apply this, thanks Arnd.

I queued this for next linux already and it's been in linux-next for a while. Sorry that I didn't reply, will try to remember to do it next time.

#5 lore raw
In reply to David Miller
Quoted 7 lines · David Miller

From: Arnd Bergmann <[email protected]>
Date: Wed, 6 Mar 2019 12:05:49 +0100

Quoted 4 lines

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:

Quoted 8 lines
Quoted 6 lines

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.

I'll apply this, thanks Arnd.

I queued this for next linux already and it's been in linux-next for a while. Sorry that I didn't reply, will try to remember to do it next time.