From: Kevin Wolf Date: Tue, 26 Jun 2018 11:22:45 +0000 (+0200) Subject: qcow2: Fix qcow2_truncate() error return value X-Git-Tag: v3.0.0-rc0~45^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ae5475e82fd1ebb24f4f77cf28f59ca6548c6136;p=thirdparty%2Fqemu.git qcow2: Fix qcow2_truncate() error return value 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 --- diff --git a/block/qcow2.c b/block/qcow2.c index a3a3aa2a97e..6b2e1e10589 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);