[RFC PATCH v1 04/17] vmstate: Set error inside of vmstate_save_field_with_vmdesc

Fabiano Rosas posted 17 patches 1 week, 2 days ago
[RFC PATCH v1 04/17] vmstate: Set error inside of vmstate_save_field_with_vmdesc
Posted by Fabiano Rosas 1 week, 2 days ago
This reduces duplication and keeps the top level less visually
polluted.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/vmstate.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/migration/vmstate.c b/migration/vmstate.c
index d7b1bc6b86..dec9cf920b 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -586,6 +586,11 @@ vmstate_save_field_with_vmdesc(QEMUFile *f, void *pv, size_t size,
 
     vmsd_desc_field_end(vmsd, vmdesc, field, written_bytes);
 
+    if (!ok) {
+        error_prepend(errp, "Save of field %s/%s failed: ",
+                      vmsd->name, field->name);
+    }
+
     return ok;
 }
 
@@ -691,8 +696,6 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,
                 }
 
                 if (!ok) {
-                    error_prepend(errp, "Save of field %s/%s failed: ",
-                                  vmsd->name, field->name);
                     goto out;
                 }
 
@@ -709,10 +712,7 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,
                                                         field->size, vmsd,
                                                         field, vmdesc_loop,
                                                         i, max_elems, errp);
-
                     if (!ok) {
-                        error_prepend(errp, "Save of field %s/%s failed: ",
-                                      vmsd->name, field->name);
                         goto out;
                     }
                 }
-- 
2.51.0