From patchwork Mon Oct 14 16:45:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 283350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8A9C52C0339 for ; Tue, 15 Oct 2013 03:48:08 +1100 (EST) Received: from localhost ([::1]:37978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVlJO-0000Gb-N9 for incoming@patchwork.ozlabs.org; Mon, 14 Oct 2013 12:48:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVlHR-0005v3-51 for qemu-devel@nongnu.org; Mon, 14 Oct 2013 12:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVlHL-0008JD-3r for qemu-devel@nongnu.org; Mon, 14 Oct 2013 12:46:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVlHK-0008Iq-St for qemu-devel@nongnu.org; Mon, 14 Oct 2013 12:45:59 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9EGjvNa031344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 14 Oct 2013 12:45:57 -0400 Received: from localhost (vpn1-5-101.gru2.redhat.com [10.97.5.101]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9EGjte3014557; Mon, 14 Oct 2013 12:45:56 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, Juan Quintela Date: Mon, 14 Oct 2013 13:45:45 -0300 Message-Id: <1381769148-22400-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1381769148-22400-1-git-send-email-ehabkost@redhat.com> References: <1381769148-22400-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Markus Armbruster Subject: [Qemu-devel] [PATCH 2/5] vmstate: Replace while (...) with for (...) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This will make it easier to add code that skips some fields, by simply using "continue". Signed-off-by: Eduardo Habkost --- savevm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/savevm.c b/savevm.c index 208e7c2..9562669 100644 --- a/savevm.c +++ b/savevm.c @@ -1676,7 +1676,7 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd, int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id) { - VMStateField *field = vmsd->fields; + VMStateField *field; int ret; if (version_id > vmsd->version_id) { @@ -1693,7 +1693,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, if (ret) return ret; } - while(field->name) { + for (field = vmsd->fields; field->name; field++) { if ((field->field_exists && field->field_exists(opaque, version_id)) || (!field->field_exists && @@ -1740,7 +1740,6 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, } } } - field++; } ret = vmstate_subsection_load(f, vmsd, opaque); if (ret != 0) { @@ -1755,12 +1754,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque) { - VMStateField *field = vmsd->fields; + VMStateField *field; if (vmsd->pre_save) { vmsd->pre_save(opaque); } - while(field->name) { + for (field = vmsd->fields; field->name; field++) { if (!field->field_exists || field->field_exists(opaque, vmsd->version_id)) { void *base_addr = opaque + field->offset; @@ -1800,7 +1799,6 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, } } } - field++; } vmstate_subsection_save(f, vmsd, opaque); }