[PATCH] libvhost-user: Fix compiler warning with -Wshadow=local

Thomas Huth posted 1 patch 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231006121129.487251-1-thuth@redhat.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
subprojects/libvhost-user/libvhost-user.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[PATCH] libvhost-user: Fix compiler warning with -Wshadow=local
Posted by Thomas Huth 7 months ago
Rename shadowing variables to make this code compilable
with -Wshadow=local.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index 051a611da3..ea2822a44c 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -870,10 +870,10 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
     for (i = 0; i < dev->nregions; i++) {
         if (reg_equal(&dev->regions[i], msg_region)) {
             VuDevRegion *r = &dev->regions[i];
-            void *m = (void *) (uintptr_t) r->mmap_addr;
+            void *ma = (void *) (uintptr_t) r->mmap_addr;
 
-            if (m) {
-                munmap(m, r->size + r->mmap_offset);
+            if (ma) {
+                munmap(ma, r->size + r->mmap_offset);
             }
 
             /*
@@ -1005,10 +1005,10 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
 
     for (i = 0; i < dev->nregions; i++) {
         VuDevRegion *r = &dev->regions[i];
-        void *m = (void *) (uintptr_t) r->mmap_addr;
+        void *ma = (void *) (uintptr_t) r->mmap_addr;
 
-        if (m) {
-            munmap(m, r->size + r->mmap_offset);
+        if (ma) {
+            munmap(ma, r->size + r->mmap_offset);
         }
     }
     dev->nregions = memory->nregions;
-- 
2.41.0
Re: [PATCH] libvhost-user: Fix compiler warning with -Wshadow=local
Posted by Markus Armbruster 6 months, 3 weeks ago
Thomas Huth <thuth@redhat.com> writes:

> Rename shadowing variables to make this code compilable
> with -Wshadow=local.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Queued.  Thanks!
Re: [PATCH] libvhost-user: Fix compiler warning with -Wshadow=local
Posted by Michael S. Tsirkin 6 months, 4 weeks ago
On Fri, Oct 06, 2023 at 02:11:29PM +0200, Thomas Huth wrote:
> Rename shadowing variables to make this code compilable
> with -Wshadow=local.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  subprojects/libvhost-user/libvhost-user.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
> index 051a611da3..ea2822a44c 100644
> --- a/subprojects/libvhost-user/libvhost-user.c
> +++ b/subprojects/libvhost-user/libvhost-user.c
> @@ -870,10 +870,10 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
>      for (i = 0; i < dev->nregions; i++) {
>          if (reg_equal(&dev->regions[i], msg_region)) {
>              VuDevRegion *r = &dev->regions[i];
> -            void *m = (void *) (uintptr_t) r->mmap_addr;
> +            void *ma = (void *) (uintptr_t) r->mmap_addr;
>  
> -            if (m) {
> -                munmap(m, r->size + r->mmap_offset);
> +            if (ma) {
> +                munmap(ma, r->size + r->mmap_offset);
>              }
>  
>              /*
> @@ -1005,10 +1005,10 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
>  
>      for (i = 0; i < dev->nregions; i++) {
>          VuDevRegion *r = &dev->regions[i];
> -        void *m = (void *) (uintptr_t) r->mmap_addr;
> +        void *ma = (void *) (uintptr_t) r->mmap_addr;
>  
> -        if (m) {
> -            munmap(m, r->size + r->mmap_offset);
> +        if (ma) {
> +            munmap(ma, r->size + r->mmap_offset);
>          }
>      }
>      dev->nregions = memory->nregions;
> -- 
> 2.41.0