From patchwork Tue Feb 11 19:23:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 319136 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 5DEDF2C00AE for ; Tue, 11 Feb 2014 17:26:02 +1100 (EST) Received: from localhost ([::1]:59727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD6nA-0006I1-8G for incoming@patchwork.ozlabs.org; Tue, 11 Feb 2014 01:26:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD6jJ-0001p3-TN for qemu-devel@nongnu.org; Tue, 11 Feb 2014 01:22:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WD6j6-0005Cc-Jv for qemu-devel@nongnu.org; Tue, 11 Feb 2014 01:22:01 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:46890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD6j5-0005CH-Vz for qemu-devel@nongnu.org; Tue, 11 Feb 2014 01:21:48 -0500 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Feb 2014 11:51:46 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 11 Feb 2014 11:51:45 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id C62D21258059 for ; Tue, 11 Feb 2014 11:53:38 +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 s1B6LehD46071968 for ; Tue, 11 Feb 2014 11:51:40 +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 s1B6LiqC025637 for ; Tue, 11 Feb 2014 11:51:44 +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 s1B6LbNM025270; Tue, 11 Feb 2014 11:51:43 +0530 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Tue, 11 Feb 2014 14:23:04 -0500 Message-Id: <1392146588-12120-5-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1392146588-12120-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1392146588-12120-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14021106-2674-0000-0000-00000CA82F4A 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 V11 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 f8390ed..a66ac9b 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);