From patchwork Sun Oct 9 19:50:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 118621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 87BA7B6F9D for ; Mon, 10 Oct 2011 07:03:42 +1100 (EST) Received: from localhost ([::1]:49808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCzaz-0004ha-7z for incoming@patchwork.ozlabs.org; Sun, 09 Oct 2011 16:03:37 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCzat-0004hA-NM for qemu-devel@nongnu.org; Sun, 09 Oct 2011 16:03:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RCzPY-0004ld-V0 for qemu-devel@nongnu.org; Sun, 09 Oct 2011 15:52:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCzPW-0004kv-KT for qemu-devel@nongnu.org; Sun, 09 Oct 2011 15:51:48 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p99JpjbN016280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 9 Oct 2011 15:51:45 -0400 Received: from neno.neno (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p99Joroo007860; Sun, 9 Oct 2011 15:51:34 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Sun, 9 Oct 2011 21:50:01 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Juan Quintela Subject: [Qemu-devel] [PATCH 3/5] savevm: define qemu_get_byte() using qemu_peek_byte() 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 Signed-off-by: Juan Quintela Signed-off-by: Juan Quintela --- savevm.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/savevm.c b/savevm.c index 4069b34..94628c6 100644 --- a/savevm.c +++ b/savevm.c @@ -578,17 +578,14 @@ static int qemu_peek_byte(QEMUFile *f) int qemu_get_byte(QEMUFile *f) { - if (f->is_write) { - abort(); - } + int result; - if (f->buf_index >= f->buf_size) { - qemu_fill_buffer(f); - if (f->buf_index >= f->buf_size) { - return 0; - } + result = qemu_peek_byte(f); + + if (f->buf_index < f->buf_size) { + f->buf_index++; } - return f->buf[f->buf_index++]; + return result; } int64_t qemu_ftell(QEMUFile *f)