Aiming to reduce one level of indentation on these routines, invert
the exists check so it can "return early" (continue actually). There
is too much code and doing it all at once would be hard to review.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/vmstate.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 5bc860129e..1862198c70 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -301,7 +301,10 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd,
trace_vmstate_load_state_field(vmsd->name, field->name, exists);
- if (exists) {
+ if (!exists) {
+ field++;
+ continue;
+ } else {
void *head;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
@@ -653,7 +656,11 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,
if (!ok) {
g_assert_not_reached();
}
- if (exists) {
+
+ if (!exists) {
+ field++;
+ continue;
+ } else {
void *head;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
--
2.51.0