[PATCH] virtio: Remove unnecessary variable assignments

Bo Liu posted 1 patch 3 years, 10 months ago
drivers/virtio/virtio_pci_modern_dev.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] virtio: Remove unnecessary variable assignments
Posted by Bo Liu 3 years, 10 months ago
In function vp_modern_probe(), "mdev->pci_dev" is assigned to
variable "pci_dev", variable "pci_dev" and "mdev->pci_dev" have
the same value. There is no need to assign variable "pci_dev" to
"mdev->pci_dev". So remove it.

Signed-off-by: Bo Liu <liubo03@inspur.com>
---
 drivers/virtio/virtio_pci_modern_dev.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c
index b790f30b2b56..fa2a9445bb18 100644
--- a/drivers/virtio/virtio_pci_modern_dev.c
+++ b/drivers/virtio/virtio_pci_modern_dev.c
@@ -220,8 +220,6 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev)
 
 	check_offsets();
 
-	mdev->pci_dev = pci_dev;
-
 	/* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */
 	if (pci_dev->device < 0x1000 || pci_dev->device > 0x107f)
 		return -ENODEV;
-- 
2.27.0
Re: [PATCH] virtio: Remove unnecessary variable assignments
Posted by Stefano Garzarella 3 years, 10 months ago
On Fri, Jun 17, 2022 at 01:59:52AM -0400, Bo Liu wrote:
>In function vp_modern_probe(), "mdev->pci_dev" is assigned to
>variable "pci_dev", variable "pci_dev" and "mdev->pci_dev" have
>the same value. There is no need to assign variable "pci_dev" to
>"mdev->pci_dev". So remove it.
>

I suggest rephrasing the description a bit.
Maybe into something like this:

     In function vp_modern_probe(), "pci_dev" is initialized with the
     value of "mdev->pci_dev", so assigning "pci_dev" to "mdev->pci_dev"
     is unnecessary since they store the same value.

Anyway, the patch LGTM:

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>Signed-off-by: Bo Liu <liubo03@inspur.com>
>---
> drivers/virtio/virtio_pci_modern_dev.c | 2 --
> 1 file changed, 2 deletions(-)
>
>diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c
>index b790f30b2b56..fa2a9445bb18 100644
>--- a/drivers/virtio/virtio_pci_modern_dev.c
>+++ b/drivers/virtio/virtio_pci_modern_dev.c
>@@ -220,8 +220,6 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev)
>
> 	check_offsets();
>
>-	mdev->pci_dev = pci_dev;
>-
> 	/* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */
> 	if (pci_dev->device < 0x1000 || pci_dev->device > 0x107f)
> 		return -ENODEV;
>-- 
>2.27.0
>