From patchwork Sun Jan 5 19:43:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 307086 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 75FBC2C00C4 for ; Mon, 6 Jan 2014 14:44:31 +1100 (EST) Received: from localhost ([::1]:60455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0177-0001qL-0b for incoming@patchwork.ozlabs.org; Sun, 05 Jan 2014 22:44:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W016J-0001jQ-2T for qemu-devel@nongnu.org; Sun, 05 Jan 2014 22:43:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W0169-0001F6-RY for qemu-devel@nongnu.org; Sun, 05 Jan 2014 22:43:38 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:52922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0169-0001Dy-7K for qemu-devel@nongnu.org; Sun, 05 Jan 2014 22:43:29 -0500 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Jan 2014 09:13:27 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 6 Jan 2014 09:13:27 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id C5B10E0053 for ; Mon, 6 Jan 2014 09:16:10 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s063hLpp52166722 for ; Mon, 6 Jan 2014 09:13:21 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s063hPiu022753 for ; Mon, 6 Jan 2014 09:13:26 +0530 Received: from RH64wenchao ([9.181.129.59]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s063hHUe022368; Mon, 6 Jan 2014 09:13:24 +0530 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Mon, 6 Jan 2014 03:43:07 +0800 Message-Id: <1388950991-30105-5-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1388950991-30105-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1388950991-30105-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14010603-2674-0000-0000-00000C28EAAB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.9 Cc: kwolf@redhat.com, peter.crosthwaite@xilinx.com, jcody@redhat.com, mreitz@redhat.com, stefanha@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V9 4/8] qcow2: return int for qcow2_free_clusters() 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 The return value can help caller check whether error happens, and it does not need to have *errp since the return value already tips what happend. Signed-off-by: Wenchao Xia Reviewed-by: Max Reitz --- block/qcow2-refcount.c | 8 +++++--- block/qcow2.h | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index c974abe..4eb413a 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -761,9 +761,9 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) return offset; } -void qcow2_free_clusters(BlockDriverState *bs, - int64_t offset, int64_t size, - enum qcow2_discard_type type) +int qcow2_free_clusters(BlockDriverState *bs, + int64_t offset, int64_t size, + enum qcow2_discard_type type) { int ret; @@ -773,6 +773,8 @@ void qcow2_free_clusters(BlockDriverState *bs, fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret)); /* TODO Remember the clusters to free them later and avoid leaking */ } + + return ret; } /* diff --git a/block/qcow2.h b/block/qcow2.h index c56a5b6..161549a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -435,9 +435,9 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size); int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int nb_clusters); int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); -void qcow2_free_clusters(BlockDriverState *bs, - int64_t offset, int64_t size, - enum qcow2_discard_type type); +int qcow2_free_clusters(BlockDriverState *bs, + int64_t offset, int64_t size, + enum qcow2_discard_type type); void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int nb_clusters, enum qcow2_discard_type type);