[PATCH] vhost-vdpa: remove useless variable

Laurent Vivier posted 1 patch 3 years, 7 months ago
Test docker-quick@centos7 passed
Test docker-mingw@fedora passed
Test checkpatch passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200920152024.860172-1-lvivier@redhat.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
hw/virtio/vhost-vdpa.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
[PATCH] vhost-vdpa: remove useless variable
Posted by Laurent Vivier 3 years, 7 months ago
in vhost_vdpa_listener_region_del(), try_unmap is always true and so,
vhost_vdpa_dma_unmap() is always called. We can remove the variable

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/virtio/vhost-vdpa.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 4580f3efd8a2..c6cae6a6cabf 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -153,7 +153,6 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
     hwaddr iova;
     Int128 llend, llsize;
     int ret;
-    bool try_unmap = true;
 
     if (vhost_vdpa_listener_skipped_section(section)) {
         return;
@@ -176,11 +175,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
 
     llsize = int128_sub(llend, int128_make64(iova));
 
-    if (try_unmap) {
-        ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
-        if (ret) {
-            error_report("vhost_vdpa dma unmap error!");
-        }
+    ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
+    if (ret) {
+        error_report("vhost_vdpa dma unmap error!");
     }
 
     memory_region_unref(section->mr);
-- 
2.26.2


Re: [PATCH] vhost-vdpa: remove useless variable
Posted by Philippe Mathieu-Daudé 3 years, 7 months ago
Cc'ing qemu-trivial@

On 9/20/20 5:20 PM, Laurent Vivier wrote:
> in vhost_vdpa_listener_region_del(), try_unmap is always true and so,
> vhost_vdpa_dma_unmap() is always called. We can remove the variable
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  hw/virtio/vhost-vdpa.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 4580f3efd8a2..c6cae6a6cabf 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -153,7 +153,6 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
>      hwaddr iova;
>      Int128 llend, llsize;
>      int ret;
> -    bool try_unmap = true;
>  
>      if (vhost_vdpa_listener_skipped_section(section)) {
>          return;
> @@ -176,11 +175,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
>  
>      llsize = int128_sub(llend, int128_make64(iova));
>  
> -    if (try_unmap) {
> -        ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
> -        if (ret) {
> -            error_report("vhost_vdpa dma unmap error!");
> -        }
> +    ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
> +    if (ret) {
> +        error_report("vhost_vdpa dma unmap error!");
>      }
>  
>      memory_region_unref(section->mr);
> 


Re: [PATCH] vhost-vdpa: remove useless variable
Posted by Laurent Vivier 3 years, 7 months ago
Le 20/09/2020 à 17:59, Philippe Mathieu-Daudé a écrit :
> Cc'ing qemu-trivial@
> 
> On 9/20/20 5:20 PM, Laurent Vivier wrote:
>> in vhost_vdpa_listener_region_del(), try_unmap is always true and so,
>> vhost_vdpa_dma_unmap() is always called. We can remove the variable
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
>> ---
>>  hw/virtio/vhost-vdpa.c | 9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
>> index 4580f3efd8a2..c6cae6a6cabf 100644
>> --- a/hw/virtio/vhost-vdpa.c
>> +++ b/hw/virtio/vhost-vdpa.c
>> @@ -153,7 +153,6 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
>>      hwaddr iova;
>>      Int128 llend, llsize;
>>      int ret;
>> -    bool try_unmap = true;
>>  
>>      if (vhost_vdpa_listener_skipped_section(section)) {
>>          return;
>> @@ -176,11 +175,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
>>  
>>      llsize = int128_sub(llend, int128_make64(iova));
>>  
>> -    if (try_unmap) {
>> -        ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
>> -        if (ret) {
>> -            error_report("vhost_vdpa dma unmap error!");
>> -        }
>> +    ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
>> +    if (ret) {
>> +        error_report("vhost_vdpa dma unmap error!");
>>      }
>>  
>>      memory_region_unref(section->mr);
>>
> 
> 

Applied to my trivial-patches branch.

Thanks,
Laurent


Re: [PATCH] vhost-vdpa: remove useless variable
Posted by Li Qiang 3 years, 7 months ago
Laurent Vivier <lvivier@redhat.com> 于2020年9月20日周日 下午11:21写道:
>
> in vhost_vdpa_listener_region_del(), try_unmap is always true and so,
> vhost_vdpa_dma_unmap() is always called. We can remove the variable
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: Li Qiang <liq3ea@gmail.com>

> ---
>  hw/virtio/vhost-vdpa.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 4580f3efd8a2..c6cae6a6cabf 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -153,7 +153,6 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
>      hwaddr iova;
>      Int128 llend, llsize;
>      int ret;
> -    bool try_unmap = true;
>
>      if (vhost_vdpa_listener_skipped_section(section)) {
>          return;
> @@ -176,11 +175,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
>
>      llsize = int128_sub(llend, int128_make64(iova));
>
> -    if (try_unmap) {
> -        ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
> -        if (ret) {
> -            error_report("vhost_vdpa dma unmap error!");
> -        }
> +    ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
> +    if (ret) {
> +        error_report("vhost_vdpa dma unmap error!");
>      }
>
>      memory_region_unref(section->mr);
> --
> 2.26.2
>
>