[PATCH 3/7] qemuMigrationParamsFromJSON: Unify return value handling with other functions

Peter Krempa posted 7 patches 5 years, 5 months ago
[PATCH 3/7] qemuMigrationParamsFromJSON: Unify return value handling with other functions
Posted by Peter Krempa 5 years, 5 months ago
This function doesn't have an overly verbose cleanup section as there
isn't any error code path. Unify it with the rest of the functions which
will simplify adding a possible error path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_migration_params.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 03d8d4fb49..3ed55c2ab4 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -670,7 +670,7 @@ qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
 qemuMigrationParamsPtr
 qemuMigrationParamsFromJSON(virJSONValuePtr params)
 {
-    qemuMigrationParamsPtr migParams;
+    g_autoptr(qemuMigrationParams) migParams = NULL;
     qemuMigrationParamValuePtr pv;
     const char *name;
     const char *str;
@@ -680,7 +680,7 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params)
         return NULL;

     if (!params)
-        return migParams;
+        return g_steal_pointer(&migParams);

     for (i = 0; i < QEMU_MIGRATION_PARAM_LAST; i++) {
         name = qemuMigrationParamTypeToString(i);
@@ -711,7 +711,7 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params)
         }
     }

-    return migParams;
+    return g_steal_pointer(&migParams);
 }


-- 
2.26.2

Re: [PATCH 3/7] qemuMigrationParamsFromJSON: Unify return value handling with other functions
Posted by Ján Tomko 5 years, 5 months ago
On a Monday in 2020, Peter Krempa wrote:
>This function doesn't have an overly verbose cleanup section as there
>isn't any error code path. Unify it with the rest of the functions which
>will simplify adding a possible error path.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_migration_params.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano