qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Fabiano Rosas <farosas@suse.de>, Peter Xu <peterx@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	Leonardo Bras <leobras@redhat.com>,
	Li Zhijian <lizhijian@fujitsu.com>
Subject: [PATCH v3 11/13] migration/rdma: Use i as for index instead of idx
Date: Wed, 11 Oct 2023 22:35:25 +0200	[thread overview]
Message-ID: <20231011203527.9061-12-quintela@redhat.com> (raw)
In-Reply-To: <20231011203527.9061-1-quintela@redhat.com>

Once there, all the uses are local to the for, so declare the variable
inside the for statement.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/rdma.c | 49 ++++++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index 932d4eda9b..e29e5551d1 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2354,7 +2354,6 @@ static int qemu_rdma_write(RDMAContext *rdma,
 static void qemu_rdma_cleanup(RDMAContext *rdma)
 {
     Error *err = NULL;
-    int idx;
 
     if (rdma->cm_id && rdma->connected) {
         if ((rdma->errored ||
@@ -2381,12 +2380,12 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
     g_free(rdma->dest_blocks);
     rdma->dest_blocks = NULL;
 
-    for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
-        if (rdma->wr_data[idx].control_mr) {
+    for (int i = 0; i < RDMA_WRID_MAX; i++) {
+        if (rdma->wr_data[i].control_mr) {
             rdma->total_registrations--;
-            ibv_dereg_mr(rdma->wr_data[idx].control_mr);
+            ibv_dereg_mr(rdma->wr_data[i].control_mr);
         }
-        rdma->wr_data[idx].control_mr = NULL;
+        rdma->wr_data[i].control_mr = NULL;
     }
 
     if (rdma->local_ram_blocks.block) {
@@ -2452,7 +2451,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
 
 static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp)
 {
-    int ret, idx;
+    int ret;
 
     /*
      * Will be validated against destination's actual capabilities
@@ -2480,18 +2479,17 @@ static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp)
 
     /* Build the hash that maps from offset to RAMBlock */
     rdma->blockmap = g_hash_table_new(g_direct_hash, g_direct_equal);
-    for (idx = 0; idx < rdma->local_ram_blocks.nb_blocks; idx++) {
+    for (int i = 0; i < rdma->local_ram_blocks.nb_blocks; i++) {
         g_hash_table_insert(rdma->blockmap,
-                (void *)(uintptr_t)rdma->local_ram_blocks.block[idx].offset,
-                &rdma->local_ram_blocks.block[idx]);
+                (void *)(uintptr_t)rdma->local_ram_blocks.block[i].offset,
+                &rdma->local_ram_blocks.block[i]);
     }
 
-    for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
-        ret = qemu_rdma_reg_control(rdma, idx);
+    for (int i = 0; i < RDMA_WRID_MAX; i++) {
+        ret = qemu_rdma_reg_control(rdma, i);
         if (ret < 0) {
-            error_setg(errp,
-                       "RDMA ERROR: rdma migration: error registering %d control!",
-                       idx);
+            error_setg(errp, "RDMA ERROR: rdma migration: error "
+                       "registering %d control!", i);
             goto err_rdma_source_init;
         }
     }
@@ -2625,16 +2623,16 @@ err_rdma_source_connect:
 static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
 {
     Error *err = NULL;
-    int ret, idx;
+    int ret;
     struct rdma_cm_id *listen_id;
     char ip[40] = "unknown";
     struct rdma_addrinfo *res, *e;
     char port_str[16];
     int reuse = 1;
 
-    for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
-        rdma->wr_data[idx].control_len = 0;
-        rdma->wr_data[idx].control_curr = NULL;
+    for (int i = 0; i < RDMA_WRID_MAX; i++) {
+        rdma->wr_data[i].control_len = 0;
+        rdma->wr_data[i].control_curr = NULL;
     }
 
     if (!rdma->host || !rdma->host[0]) {
@@ -2723,11 +2721,9 @@ err_dest_init_create_listen_id:
 static void qemu_rdma_return_path_dest_init(RDMAContext *rdma_return_path,
                                             RDMAContext *rdma)
 {
-    int idx;
-
-    for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
-        rdma_return_path->wr_data[idx].control_len = 0;
-        rdma_return_path->wr_data[idx].control_curr = NULL;
+    for (int i = 0; i < RDMA_WRID_MAX; i++) {
+        rdma_return_path->wr_data[i].control_len = 0;
+        rdma_return_path->wr_data[i].control_curr = NULL;
     }
 
     /*the CM channel and CM id is shared*/
@@ -3377,7 +3373,6 @@ static int qemu_rdma_accept(RDMAContext *rdma)
     struct rdma_cm_event *cm_event;
     struct ibv_context *verbs;
     int ret;
-    int idx;
 
     ret = rdma_get_cm_event(rdma->channel, &cm_event);
     if (ret < 0) {
@@ -3463,10 +3458,10 @@ static int qemu_rdma_accept(RDMAContext *rdma)
 
     qemu_rdma_init_ram_blocks(rdma);
 
-    for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
-        ret = qemu_rdma_reg_control(rdma, idx);
+    for (int i = 0; i < RDMA_WRID_MAX; i++) {
+        ret = qemu_rdma_reg_control(rdma, i);
         if (ret < 0) {
-            error_report("rdma: error registering %d control", idx);
+            error_report("rdma: error registering %d control", i);
             goto err_rdma_dest_wait;
         }
     }
-- 
2.41.0



  parent reply	other threads:[~2023-10-11 20:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 20:35 [PATCH v3 00/13] Removal of QEMUFileHooks Juan Quintela
2023-10-11 20:35 ` [PATCH v3 01/13] migration: Create migrate_rdma() Juan Quintela
2023-10-13  7:58   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 02/13] migration/rdma: Unfold ram_control_before_iterate() Juan Quintela
2023-10-12 14:21   ` Fabiano Rosas
2023-10-13  8:24   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 03/13] migration/rdma: Unfold ram_control_after_iterate() Juan Quintela
2023-10-13  7:59   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 04/13] migration/rdma: Remove all uses of RAM_CONTROL_HOOK Juan Quintela
2023-10-13  8:00   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 05/13] migration/rdma: Unfold hook_ram_load() Juan Quintela
2023-10-13  8:02   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 06/13] migration/rdma: Create rdma_control_save_page() Juan Quintela
2023-10-13  8:05   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 07/13] qemu-file: Remove QEMUFileHooks Juan Quintela
2023-10-13  8:07   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 08/13] migration/rdma: Move rdma constants from qemu-file.h to rdma.h Juan Quintela
2023-10-13  8:08   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 09/13] migration/rdma: Remove qemu_ prefix from exported functions Juan Quintela
2023-10-13  8:09   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 10/13] migration/rdma: Check sooner if we are in postcopy for save_page() Juan Quintela
2023-10-13  8:11   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` Juan Quintela [this message]
2023-10-12 14:30   ` [PATCH v3 11/13] migration/rdma: Use i as for index instead of idx Fabiano Rosas
2023-10-13  8:13   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 12/13] migration/rdma: Declare for index variables local Juan Quintela
2023-10-12 14:33   ` Fabiano Rosas
2023-10-13  8:17   ` Zhijian Li (Fujitsu)
2023-10-11 20:35 ` [PATCH v3 13/13] migration/rdma: Remove all "ret" variables that are used only once Juan Quintela
2023-10-12 14:44   ` Fabiano Rosas
2023-10-16  6:36     ` Juan Quintela
2023-10-13  8:19   ` Zhijian Li (Fujitsu)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231011203527.9061-12-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=farosas@suse.de \
    --cc=leobras@redhat.com \
    --cc=lizhijian@fujitsu.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).