From patchwork Fri Feb 22 16:36:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 222575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9DB3A2C029C for ; Sat, 23 Feb 2013 04:12:23 +1100 (EST) Received: from localhost ([::1]:56166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8vdW-0005rz-M9 for incoming@patchwork.ozlabs.org; Fri, 22 Feb 2013 11:38:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8vce-0004IX-DL for qemu-devel@nongnu.org; Fri, 22 Feb 2013 11:37:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8vcd-0006he-33 for qemu-devel@nongnu.org; Fri, 22 Feb 2013 11:37:20 -0500 Received: from mail-ve0-f178.google.com ([209.85.128.178]:48136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8vcc-0006hW-VD for qemu-devel@nongnu.org; Fri, 22 Feb 2013 11:37:19 -0500 Received: by mail-ve0-f178.google.com with SMTP id db10so713644veb.9 for ; Fri, 22 Feb 2013 08:37:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=i3Ls+JmjXAjvu7ERcmS4hOqQSJbtqFkolTNMOyRj4gg=; b=OiR/qYq06lnCIaYpezTOCre9WxcdNstTiKyB96IGhbJoNadTrQt1jhRrb51rQwDqTx nuJM6cWsAlTOLJdruhvMxxIKUkwYFrjDljGRkczheD3I2hjPMifF124tKzbzd5xTB/LC r8AhL/1jOhGtk5EfsOIJ7YjrJkbIaHDscS2eXwAEFnyeRPlzVQAiZD9EtETSiFXiPust y23/CT2u4LHH+3j8t9Yerjvr9kUrpVtinrwGF28ZiP3o7xnUdiewwIVyNCxbyt9PBgLn BCa66MiDqzMMuMcrgj+w46DymMxxtPZTRNO2v2O9U9cnhjZNi7cqw9q26SQJgfSoP+4s zD+g== X-Received: by 10.52.89.48 with SMTP id bl16mr2911043vdb.120.1361551033380; Fri, 22 Feb 2013 08:37:13 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id tp10sm4291733vec.1.2013.02.22.08.37.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 Feb 2013 08:37:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2013 17:36:12 +0100 Message-Id: <1361551008-12430-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361551008-12430-1-git-send-email-pbonzini@redhat.com> References: <1361551008-12430-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.128.178 Cc: owasserm@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 06/42] qemu-file: pass errno from qemu_fflush via f->last_error 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 is done by almost all callers of qemu_fflush, move the code directly to qemu_fflush. Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela Signed-off-by: Paolo Bonzini --- savevm.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/savevm.c b/savevm.c index 4302903..a681177 100644 --- a/savevm.c +++ b/savevm.c @@ -453,13 +453,13 @@ static void qemu_file_set_error(QEMUFile *f, int ret) /** Flushes QEMUFile buffer * */ -static int qemu_fflush(QEMUFile *f) +static void qemu_fflush(QEMUFile *f) { int ret = 0; - if (!f->ops->put_buffer) - return 0; - + if (!f->ops->put_buffer) { + return; + } if (f->is_write && f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->buf_offset, f->buf_index); if (ret >= 0) { @@ -467,7 +467,9 @@ static int qemu_fflush(QEMUFile *f) } f->buf_index = 0; } - return ret; + if (ret < 0) { + qemu_file_set_error(f, ret); + } } static void qemu_fill_buffer(QEMUFile *f) @@ -518,7 +520,8 @@ int qemu_get_fd(QEMUFile *f) int qemu_fclose(QEMUFile *f) { int ret; - ret = qemu_fflush(f); + qemu_fflush(f); + ret = qemu_file_get_error(f); if (f->ops->close) { int ret2 = f->ops->close(f->opaque); @@ -560,9 +563,8 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) buf += l; size -= l; if (f->buf_index >= IO_BUF_SIZE) { - int ret = qemu_fflush(f); - if (ret < 0) { - qemu_file_set_error(f, ret); + qemu_fflush(f); + if (qemu_file_get_error(f)) { break; } } @@ -584,10 +586,7 @@ void qemu_put_byte(QEMUFile *f, int v) f->buf[f->buf_index++] = v; f->is_write = 1; if (f->buf_index >= IO_BUF_SIZE) { - int ret = qemu_fflush(f); - if (ret < 0) { - qemu_file_set_error(f, ret); - } + qemu_fflush(f); } }