diff mbox series

[27/52] migration/rdma: Drop superfluous assignments to @ret

Message ID 20230918144206.560120-28-armbru@redhat.com
State New
Headers show
Series migration/rdma: Error handling fixes | expand

Commit Message

Markus Armbruster Sept. 18, 2023, 2:41 p.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 migration/rdma.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

Comments

Li Zhijian Sept. 25, 2023, 6:20 a.m. UTC | #1
On 18/09/2023 22:41, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>


> ---
>   migration/rdma.c | 35 ++++++++++-------------------------
>   1 file changed, 10 insertions(+), 25 deletions(-)
> 
> diff --git a/migration/rdma.c b/migration/rdma.c
> index 85f6b274bf..62d95b7d2c 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -1514,7 +1514,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
>                                          struct ibv_comp_channel *comp_channel)
>   {
>       struct rdma_cm_event *cm_event;
> -    int ret = -1;
> +    int ret;
>   
>       /*
>        * Coroutine doesn't start until migration_fd_process_incoming()
> @@ -1619,7 +1619,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma,
>                                       uint64_t wrid_requested,
>                                       uint32_t *byte_len)
>   {
> -    int num_cq_events = 0, ret = 0;
> +    int num_cq_events = 0, ret;
>       struct ibv_cq *cq;
>       void *cq_ctx;
>       uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
> @@ -1664,8 +1664,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma,
>   
>           num_cq_events++;
>   
> -        ret = -ibv_req_notify_cq(cq, 0);
> -        if (ret) {
> +        if (ibv_req_notify_cq(cq, 0)) {
>               goto err_block_for_wrid;
>           }
>   
> @@ -1712,7 +1711,7 @@ err_block_for_wrid:
>   static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
>                                          RDMAControlHeader *head)
>   {
> -    int ret = 0;
> +    int ret;
>       RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_CONTROL];
>       struct ibv_send_wr *bad_wr;
>       struct ibv_sge sge = {
> @@ -1869,7 +1868,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
>                                      int *resp_idx,
>                                      int (*callback)(RDMAContext *rdma))
>   {
> -    int ret = 0;
> +    int ret;
>   
>       /*
>        * Wait until the dest is ready before attempting to deliver the message
> @@ -2841,7 +2840,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc,
>       QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc);
>       RDMAContext *rdma;
>       RDMAControlHeader head;
> -    int ret = 0;
> +    int ret;
>       size_t i;
>       size_t done = 0;
>   
> @@ -3340,7 +3339,7 @@ static int qemu_rdma_accept(RDMAContext *rdma)
>       RDMAContext *rdma_return_path = NULL;
>       struct rdma_cm_event *cm_event;
>       struct ibv_context *verbs;
> -    int ret = -EINVAL;
> +    int ret;
>       int idx;
>   
>       ret = rdma_get_cm_event(rdma->channel, &cm_event);
> @@ -3350,7 +3349,6 @@ static int qemu_rdma_accept(RDMAContext *rdma)
>   
>       if (cm_event->event != RDMA_CM_EVENT_CONNECT_REQUEST) {
>           rdma_ack_cm_event(cm_event);
> -        ret = -1;
>           goto err_rdma_dest_wait;
>       }
>   
> @@ -3363,7 +3361,6 @@ static int qemu_rdma_accept(RDMAContext *rdma)
>           rdma_return_path = qemu_rdma_data_init(rdma->host_port, NULL);
>           if (rdma_return_path == NULL) {
>               rdma_ack_cm_event(cm_event);
> -            ret = -1;
>               goto err_rdma_dest_wait;
>           }
>   
> @@ -3378,7 +3375,6 @@ static int qemu_rdma_accept(RDMAContext *rdma)
>           error_report("Unknown source RDMA version: %d, bailing...",
>                        cap.version);
>           rdma_ack_cm_event(cm_event);
> -        ret = -1;
>           goto err_rdma_dest_wait;
>       }
>   
> @@ -3411,7 +3407,6 @@ static int qemu_rdma_accept(RDMAContext *rdma)
>       } else if (rdma->verbs != verbs) {
>           error_report("ibv context not matching %p, %p!", rdma->verbs,
>                        verbs);
> -        ret = -1;
>           goto err_rdma_dest_wait;
>       }
>   
> @@ -3465,7 +3460,6 @@ static int qemu_rdma_accept(RDMAContext *rdma)
>       if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) {
>           error_report("rdma_accept not event established");
>           rdma_ack_cm_event(cm_event);
> -        ret = -1;
>           goto err_rdma_dest_wait;
>       }
>   
> @@ -3528,7 +3522,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>       static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE];
>       RDMALocalBlock *block;
>       void *host_addr;
> -    int ret = 0;
> +    int ret;
>       int idx = 0;
>       int count = 0;
>       int i = 0;
> @@ -3557,7 +3551,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>           if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) {
>               error_report("rdma: Too many requests in this message (%d)."
>                               "Bailing.", head.repeat);
> -            ret = -EIO;
>               break;
>           }
>   
> @@ -3573,7 +3566,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>                   error_report("rdma: 'compress' bad block index %u (vs %d)",
>                                (unsigned int)comp->block_idx,
>                                rdma->local_ram_blocks.nb_blocks);
> -                ret = -EIO;
>                   goto err;
>               }
>               block = &(rdma->local_ram_blocks.block[comp->block_idx]);
> @@ -3672,7 +3664,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>                       error_report("rdma: 'register' bad block index %u (vs %d)",
>                                    (unsigned int)reg->current_index,
>                                    rdma->local_ram_blocks.nb_blocks);
> -                    ret = -ENOENT;
>                       goto err;
>                   }
>                   block = &(rdma->local_ram_blocks.block[reg->current_index]);
> @@ -3682,7 +3673,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>                               " offset: %" PRIx64 " current_addr: %" PRIx64,
>                               block->block_name, block->offset,
>                               reg->key.current_addr);
> -                        ret = -ERANGE;
>                           goto err;
>                       }
>                       host_addr = (block->local_host_addr +
> @@ -3698,7 +3688,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>                           error_report("rdma: bad chunk for block %s"
>                               " chunk: %" PRIx64,
>                               block->block_name, reg->key.chunk);
> -                        ret = -ERANGE;
>                           goto err;
>                       }
>                   }
> @@ -3710,7 +3699,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>                               (uintptr_t)host_addr, NULL, &tmp_rkey,
>                               chunk, chunk_start, chunk_end)) {
>                       error_report("cannot get rkey");
> -                    ret = -EINVAL;
>                       goto err;
>                   }
>                   reg_result->rkey = tmp_rkey;
> @@ -3750,7 +3738,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>   
>                   if (ret != 0) {
>                       perror("rdma unregistration chunk failed");
> -                    ret = -ret;
>                       goto err;
>                   }
>   
> @@ -3769,11 +3756,9 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
>               break;
>           case RDMA_CONTROL_REGISTER_RESULT:
>               error_report("Invalid RESULT message at dest.");
> -            ret = -EIO;
>               goto err;
>           default:
>               error_report("Unknown control message %s", control_desc(head.type));
> -            ret = -EIO;
>               goto err;
>           }
>       } while (1);
> @@ -3877,7 +3862,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f,
>       QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
>       RDMAContext *rdma;
>       RDMAControlHeader head = { .len = 0, .repeat = 1 };
> -    int ret = 0;
> +    int ret;
>   
>       if (migration_in_postcopy()) {
>           return 0;
> @@ -4151,7 +4136,7 @@ void rdma_start_outgoing_migration(void *opaque,
>       MigrationState *s = opaque;
>       RDMAContext *rdma_return_path = NULL;
>       RDMAContext *rdma;
> -    int ret = 0;
> +    int ret;
>   
>       /* Avoid ram_block_discard_disable(), cannot change during migration. */
>       if (ram_block_discard_is_required()) {
diff mbox series

Patch

diff --git a/migration/rdma.c b/migration/rdma.c
index 85f6b274bf..62d95b7d2c 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1514,7 +1514,7 @@  static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
                                        struct ibv_comp_channel *comp_channel)
 {
     struct rdma_cm_event *cm_event;
-    int ret = -1;
+    int ret;
 
     /*
      * Coroutine doesn't start until migration_fd_process_incoming()
@@ -1619,7 +1619,7 @@  static int qemu_rdma_block_for_wrid(RDMAContext *rdma,
                                     uint64_t wrid_requested,
                                     uint32_t *byte_len)
 {
-    int num_cq_events = 0, ret = 0;
+    int num_cq_events = 0, ret;
     struct ibv_cq *cq;
     void *cq_ctx;
     uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
@@ -1664,8 +1664,7 @@  static int qemu_rdma_block_for_wrid(RDMAContext *rdma,
 
         num_cq_events++;
 
-        ret = -ibv_req_notify_cq(cq, 0);
-        if (ret) {
+        if (ibv_req_notify_cq(cq, 0)) {
             goto err_block_for_wrid;
         }
 
@@ -1712,7 +1711,7 @@  err_block_for_wrid:
 static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
                                        RDMAControlHeader *head)
 {
-    int ret = 0;
+    int ret;
     RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_CONTROL];
     struct ibv_send_wr *bad_wr;
     struct ibv_sge sge = {
@@ -1869,7 +1868,7 @@  static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
                                    int *resp_idx,
                                    int (*callback)(RDMAContext *rdma))
 {
-    int ret = 0;
+    int ret;
 
     /*
      * Wait until the dest is ready before attempting to deliver the message
@@ -2841,7 +2840,7 @@  static ssize_t qio_channel_rdma_readv(QIOChannel *ioc,
     QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc);
     RDMAContext *rdma;
     RDMAControlHeader head;
-    int ret = 0;
+    int ret;
     size_t i;
     size_t done = 0;
 
@@ -3340,7 +3339,7 @@  static int qemu_rdma_accept(RDMAContext *rdma)
     RDMAContext *rdma_return_path = NULL;
     struct rdma_cm_event *cm_event;
     struct ibv_context *verbs;
-    int ret = -EINVAL;
+    int ret;
     int idx;
 
     ret = rdma_get_cm_event(rdma->channel, &cm_event);
@@ -3350,7 +3349,6 @@  static int qemu_rdma_accept(RDMAContext *rdma)
 
     if (cm_event->event != RDMA_CM_EVENT_CONNECT_REQUEST) {
         rdma_ack_cm_event(cm_event);
-        ret = -1;
         goto err_rdma_dest_wait;
     }
 
@@ -3363,7 +3361,6 @@  static int qemu_rdma_accept(RDMAContext *rdma)
         rdma_return_path = qemu_rdma_data_init(rdma->host_port, NULL);
         if (rdma_return_path == NULL) {
             rdma_ack_cm_event(cm_event);
-            ret = -1;
             goto err_rdma_dest_wait;
         }
 
@@ -3378,7 +3375,6 @@  static int qemu_rdma_accept(RDMAContext *rdma)
         error_report("Unknown source RDMA version: %d, bailing...",
                      cap.version);
         rdma_ack_cm_event(cm_event);
-        ret = -1;
         goto err_rdma_dest_wait;
     }
 
@@ -3411,7 +3407,6 @@  static int qemu_rdma_accept(RDMAContext *rdma)
     } else if (rdma->verbs != verbs) {
         error_report("ibv context not matching %p, %p!", rdma->verbs,
                      verbs);
-        ret = -1;
         goto err_rdma_dest_wait;
     }
 
@@ -3465,7 +3460,6 @@  static int qemu_rdma_accept(RDMAContext *rdma)
     if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) {
         error_report("rdma_accept not event established");
         rdma_ack_cm_event(cm_event);
-        ret = -1;
         goto err_rdma_dest_wait;
     }
 
@@ -3528,7 +3522,7 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
     static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE];
     RDMALocalBlock *block;
     void *host_addr;
-    int ret = 0;
+    int ret;
     int idx = 0;
     int count = 0;
     int i = 0;
@@ -3557,7 +3551,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
         if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) {
             error_report("rdma: Too many requests in this message (%d)."
                             "Bailing.", head.repeat);
-            ret = -EIO;
             break;
         }
 
@@ -3573,7 +3566,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
                 error_report("rdma: 'compress' bad block index %u (vs %d)",
                              (unsigned int)comp->block_idx,
                              rdma->local_ram_blocks.nb_blocks);
-                ret = -EIO;
                 goto err;
             }
             block = &(rdma->local_ram_blocks.block[comp->block_idx]);
@@ -3672,7 +3664,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
                     error_report("rdma: 'register' bad block index %u (vs %d)",
                                  (unsigned int)reg->current_index,
                                  rdma->local_ram_blocks.nb_blocks);
-                    ret = -ENOENT;
                     goto err;
                 }
                 block = &(rdma->local_ram_blocks.block[reg->current_index]);
@@ -3682,7 +3673,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
                             " offset: %" PRIx64 " current_addr: %" PRIx64,
                             block->block_name, block->offset,
                             reg->key.current_addr);
-                        ret = -ERANGE;
                         goto err;
                     }
                     host_addr = (block->local_host_addr +
@@ -3698,7 +3688,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
                         error_report("rdma: bad chunk for block %s"
                             " chunk: %" PRIx64,
                             block->block_name, reg->key.chunk);
-                        ret = -ERANGE;
                         goto err;
                     }
                 }
@@ -3710,7 +3699,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
                             (uintptr_t)host_addr, NULL, &tmp_rkey,
                             chunk, chunk_start, chunk_end)) {
                     error_report("cannot get rkey");
-                    ret = -EINVAL;
                     goto err;
                 }
                 reg_result->rkey = tmp_rkey;
@@ -3750,7 +3738,6 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
 
                 if (ret != 0) {
                     perror("rdma unregistration chunk failed");
-                    ret = -ret;
                     goto err;
                 }
 
@@ -3769,11 +3756,9 @@  static int qemu_rdma_registration_handle(QEMUFile *f)
             break;
         case RDMA_CONTROL_REGISTER_RESULT:
             error_report("Invalid RESULT message at dest.");
-            ret = -EIO;
             goto err;
         default:
             error_report("Unknown control message %s", control_desc(head.type));
-            ret = -EIO;
             goto err;
         }
     } while (1);
@@ -3877,7 +3862,7 @@  static int qemu_rdma_registration_stop(QEMUFile *f,
     QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
     RDMAContext *rdma;
     RDMAControlHeader head = { .len = 0, .repeat = 1 };
-    int ret = 0;
+    int ret;
 
     if (migration_in_postcopy()) {
         return 0;
@@ -4151,7 +4136,7 @@  void rdma_start_outgoing_migration(void *opaque,
     MigrationState *s = opaque;
     RDMAContext *rdma_return_path = NULL;
     RDMAContext *rdma;
-    int ret = 0;
+    int ret;
 
     /* Avoid ram_block_discard_disable(), cannot change during migration. */
     if (ram_block_discard_is_required()) {