From patchwork Thu Oct 6 16:21:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 118125 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 07134B6F94 for ; Fri, 7 Oct 2011 03:22:50 +1100 (EST) Received: from localhost ([::1]:60913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBqiS-0007sQ-0T for incoming@patchwork.ozlabs.org; Thu, 06 Oct 2011 12:22:36 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBqhl-0005xF-Nt for qemu-devel@nongnu.org; Thu, 06 Oct 2011 12:21:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBqhk-0005Sh-K7 for qemu-devel@nongnu.org; Thu, 06 Oct 2011 12:21:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBqhk-0005SX-Al for qemu-devel@nongnu.org; Thu, 06 Oct 2011 12:21:52 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p96GLpnc020637 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Oct 2011 12:21:51 -0400 Received: from trasno.mitica (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p96GLkPn024808; Thu, 6 Oct 2011 12:21:50 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 6 Oct 2011 18:21:38 +0200 Message-Id: <49696d43bab6d485d414cfe58772c9ac54926b63.1317911543.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 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 --- 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)