Skip to contentSkip to conversation

vdpa: fix warning casts when building with C=2

PATCH In review Stefano Garzarella 2 participants 3 messages Aug 11, 2022 – Oct 7, 2022 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vdpa: fix warning casts when building with C=2

Use __virtio16_to_cpu() to read max_virtqueue_pairs field in virtio_net_config since its type is __virtio16.

This silences the following warning when building with make C=2:

    ../drivers/vdpa/vdpa.c:811:19: warning: cast to restricted __le16
    ../drivers/vdpa/vdpa.c:811:19: warning: cast from restricted __virtio16
---
 drivers/vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/vdpa.c +1 -1
index c06c02704461..2466d5087478 100644
@@ -808,7 +808,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
 	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
 		return 0;
 
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
+	val_u16 = __virtio16_to_cpu(true, config->max_virtqueue_pairs);
 	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
 }
 
Signature · 1 line
2.37.1
#1 lore raw
Quoted 9 lines · Stefano Garzarella

Use __virtio16_to_cpu() to read max_virtqueue_pairs field in virtio_net_config since its type is __virtio16.

This silences the following warning when building with make C=2:

    ../drivers/vdpa/vdpa.c:811:19: warning: cast to restricted __le16
    ../drivers/vdpa/vdpa.c:811:19: warning: cast from restricted __virtio16

I just noticed that we still have these warnings, maybe this patch has fallen through the cracks, so I just ping kindly to include it in this merge window :-)

Thanks,
Stefano

Quoted 19 lines
---
 drivers/vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/vdpa.c +1 -2
index c06c02704461..2466d5087478 100644
@@ -808,7 +808,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
        if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
                return 0;
 
-       val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
+       val_u16 = __virtio16_to_cpu(true, config->max_virtqueue_pairs);
        return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
 }
 
--
Quoted 2 lines

2.37.1

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

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Stefano Garzarella
Quoted 10 lines · Stefano Garzarella

Use __virtio16_to_cpu() to read max_virtqueue_pairs field in virtio_net_config since its type is __virtio16.

This silences the following warning when building with make C=2:

    ../drivers/vdpa/vdpa.c:811:19: warning: cast to restricted __le16
    ../drivers/vdpa/vdpa.c:811:19: warning: cast from restricted __virtio16
Quoted 20 lines
---
 drivers/vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/vdpa.c +1 -2
index c06c02704461..2466d5087478 100644
@@ -808,7 +808,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
        if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
                return 0;
 
-       val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
+       val_u16 = __virtio16_to_cpu(true, config->max_virtqueue_pairs);
        return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
 }
 
--

2.37.1