From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYu6N-0003q7-WF for qemu-devel@nongnu.org; Fri, 29 Jun 2018 10:10:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYu6M-0003nS-MX for qemu-devel@nongnu.org; Fri, 29 Jun 2018 10:10:19 -0400 From: Kevin Wolf Date: Fri, 29 Jun 2018 16:09:36 +0200 Message-Id: <20180629140959.6690-7-kwolf@redhat.com> In-Reply-To: <20180629140959.6690-1-kwolf@redhat.com> References: <20180629140959.6690-1-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 06/29] qcow2: Fix qcow2_truncate() error return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org If qcow2_alloc_clusters_at() returns an error, we do need to negate it to get back the positive errno code for error_setg_errno(), but we still need to return the negative error code. Fixes: 772d1f973f87269f6a4a4ea4b880680f3779bbdf Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index a3a3aa2a97..6b2e1e1058 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3597,7 +3597,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset, if (clusters_allocated < 0) { error_setg_errno(errp, -clusters_allocated, "Failed to allocate data clusters"); - return -clusters_allocated; + return clusters_allocated; } assert(clusters_allocated == nb_new_data_clusters); -- 2.13.6