diff mbox series

[10/11] migration: Remove unnecessary usage of local Error

Message ID 20231231093016.14204-11-avihaih@nvidia.com (mailing list archive)
State New, archived
Headers show
Series migration: Misc cleanups and fixes | expand

Commit Message

Avihai Horon Dec. 31, 2023, 9:30 a.m. UTC
According to Error API, usage of ERRP_GUARD() or a local Error instead
of errp is needed if errp is passed to void functions, where it is later
dereferenced to see if an error occurred.

There are several places in migration.c that use local Error although it
is not needed. Change these places to use errp directly.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
 migration/migration.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Fabiano Rosas Jan. 2, 2024, 7:42 p.m. UTC | #1
Avihai Horon <avihaih@nvidia.com> writes:

> According to Error API, usage of ERRP_GUARD() or a local Error instead
> of errp is needed if errp is passed to void functions, where it is later
> dereferenced to see if an error occurred.
>
> There are several places in migration.c that use local Error although it
> is not needed. Change these places to use errp directly.
>
> Signed-off-by: Avihai Horon <avihaih@nvidia.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>
diff mbox series

Patch

diff --git a/migration/migration.c b/migration/migration.c
index b0c3b4c23a..fc7f4fd263 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -830,10 +830,9 @@  void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
          * issue is not possible.
          */
         ret = migration_channel_read_peek(ioc, (void *)&channel_magic,
-                                          sizeof(channel_magic), &local_err);
+                                          sizeof(channel_magic), errp);
 
         if (ret != 0) {
-            error_propagate(errp, local_err);
             return;
         }
 
@@ -1825,8 +1824,6 @@  bool migration_is_blocked(Error **errp)
 static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
                             bool resume, Error **errp)
 {
-    Error *local_err = NULL;
-
     if (blk_inc) {
         warn_report("parameter 'inc' is deprecated;"
                     " use blockdev-mirror with NBD instead");
@@ -1896,8 +1893,7 @@  static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
                        "current migration capabilities");
             return false;
         }
-        if (!migrate_cap_set(MIGRATION_CAPABILITY_BLOCK, true, &local_err)) {
-            error_propagate(errp, local_err);
+        if (!migrate_cap_set(MIGRATION_CAPABILITY_BLOCK, true, errp)) {
             return false;
         }
         s->must_remove_block_options = true;