Skip to contentSkip to conversation

migration/ram: Fix compilation with -Wshadow=local

PATCH In review Thomas Huth 3 participants 4 messages Oct 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 migration/ram: Fix compilation with -Wshadow=local

Rename the variable here to avoid that it shadows a variable from the beginning of the function scope. With this change the code now successfully compiles with -Wshadow=local.

---
v2: Need the value for the qemu_file_set_error() line, too

 migration/ram.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
migration/ram.c +5 -3
index 92769902bb..212add4481 100644
@@ -3208,6 +3208,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
     rs->last_stage = !migration_in_colo_state();
 
     WITH_RCU_READ_LOCK_GUARD() {
+        int rdma_reg_ret;
+
         if (!migration_in_postcopy()) {
             migration_bitmap_sync_precopy(rs, true);
         }
@@ -3238,9 +3240,9 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
 
         ram_flush_compressed_data(rs);
 
-        int ret = rdma_registration_stop(f, RAM_CONTROL_FINISH);
-        if (ret < 0) {
-            qemu_file_set_error(f, ret);
+        rdma_reg_ret = rdma_registration_stop(f, RAM_CONTROL_FINISH);
+        if (rdma_reg_ret < 0) {
+            qemu_file_set_error(f, rdma_reg_ret);
         }
     }
 
Signature · 1 line
2.41.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Thomas Huth

Rename the variable here to avoid that it shadows a variable from the beginning of the function scope. With this change the code now successfully compiles with -Wshadow=local.

queued.

Quoted 2 lines

---
v2: Need the value for the qemu_file_set_error() line, too

I also hate qemu_file_set_error().

Direct translation of Spanish Saying:

Evil of many, consolation of fools

O:-)

Reviewed-by on v2 1/1
#3 lore raw
In reply to Thomas Huth
Quoted 26 lines · Thomas Huth

Rename the variable here to avoid that it shadows a variable from the beginning of the function scope. With this change the code now successfully compiles with -Wshadow=local.

---
v2: Need the value for the qemu_file_set_error() line, too

 migration/ram.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
migration/ram.c +2 -0
index 92769902bb..212add4481 100644
@@ -3208,6 +3208,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
     rs->last_stage = !migration_in_colo_state();
 
     WITH_RCU_READ_LOCK_GUARD() {
+        int rdma_reg_ret;
+
         if (!migration_in_postcopy()) {
             migration_bitmap_sync_precopy(rs, true);
         }
@@ -3238,9 +3240,9 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
 

migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3247

Quoted 10 lines
migration/ram.c +3 -3
         ram_flush_compressed_data(rs);
 
-        int ret = rdma_registration_stop(f, RAM_CONTROL_FINISH);
-        if (ret < 0) {
-            qemu_file_set_error(f, ret);
+        rdma_reg_ret = rdma_registration_stop(f, RAM_CONTROL_FINISH);
+        if (rdma_reg_ret < 0) {
+            qemu_file_set_error(f, rdma_reg_ret);
         }
     }

Still ugly, but we want a minimally invasive fix now, and this is one.

and queued. Thanks!

#2 lore raw
In reply to Juan Quintela
Quoted 10 lines · Juan Quintela
Quoted 5 lines · Thomas Huth

Rename the variable here to avoid that it shadows a variable from the beginning of the function scope. With this change the code now successfully compiles with -Wshadow=local.

queued.

I'm going to post a patch to enable -Wshadow=local, based on all the outstanding shadow fixes, including this one. When I do the PR for the enabling patch, I'll need to include any outstanding shadow fixes. Should be fine no matter how it races with your PR.

Quoted 10 lines
Quoted 2 lines

---
v2: Need the value for the qemu_file_set_error() line, too

I also hate qemu_file_set_error().

Direct translation of Spanish Saying:

Evil of many, consolation of fools

O:-)

Good one!