Received: from eggs.gnu.org ([2001:4830:134:3::10]:42217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WILHV-0003LY-KT for qemu-devel@nongnu.org; Tue, 25 Feb 2014 11:55:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WILHO-0002RX-U2 for qemu-devel@nongnu.org; Tue, 25 Feb 2014 11:54:57 -0500 Received: from mail-wg0-f46.google.com ([74.125.82.46]:48947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WILHO-0002RQ-Nf for qemu-devel@nongnu.org; Tue, 25 Feb 2014 11:54:50 -0500 Received: by mail-wg0-f46.google.com with SMTP id z12so632441wgg.17 for ; Tue, 25 Feb 2014 08:54:50 -0800 (PST) From: Alvise Rigo Date: Tue, 25 Feb 2014 17:52:47 +0100 Message-Id: <1393347170-28502-2-git-send-email-a.rigo@virtualopensystems.com> In-Reply-To: <1393347170-28502-1-git-send-email-a.rigo@virtualopensystems.com> References: <1393347170-28502-1-git-send-email-a.rigo@virtualopensystems.com> Subject: [Qemu-devel] [RFC 1/4] Fix issue affecting get_int32_le() in vmstate.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Orit Wasserman , tech@virtualopensystems.com, Alvise Rigo , Eduardo Habkost , Juan Quintela The method is not behaving in the way it's supposed to. It should return the new value only if it's less than the actual one. Signed-off-by: Alvise Rigo --- vmstate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vmstate.c b/vmstate.c index 284b080..038b274 100644 --- a/vmstate.c +++ b/vmstate.c @@ -326,11 +326,11 @@ const VMStateInfo vmstate_info_int32_equal = { static int get_int32_le(QEMUFile *f, void *pv, size_t size) { - int32_t *old = pv; - int32_t new; - qemu_get_sbe32s(f, &new); + int32_t old = *(int32_t *)pv; + int32_t *new = pv; + qemu_get_sbe32s(f, new); - if (*old <= new) { + if (*new <= old) { return 0; } return -EINVAL; -- 1.8.3.2