block: Don't try to set *errp directly

Assigning directly to *errp is not valid, as errp may be NULL,
&error_fatal, or &error_abort.  Use error_propagate() instead.

With this, there's no need to check if errp is NULL anymore, as
error_propagate() and error_prepend() are able to handle that.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170608133906.12737-3-ehabkost@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
master
Eduardo Habkost 2017-06-08 10:39:03 -03:00 committed by Markus Armbruster
parent a9859c90a5
commit 57ef3f1278
1 changed files with 3 additions and 5 deletions

View File

@ -4267,11 +4267,9 @@ bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp)
assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
if (!QLIST_EMPTY(&bs->op_blockers[op])) {
blocker = QLIST_FIRST(&bs->op_blockers[op]);
if (errp) {
*errp = error_copy(blocker->reason);
error_prepend(errp, "Node '%s' is busy: ",
bdrv_get_device_or_node_name(bs));
}
error_propagate(errp, error_copy(blocker->reason));
error_prepend(errp, "Node '%s' is busy: ",
bdrv_get_device_or_node_name(bs));
return true;
}
return false;