aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2014-01-24 14:11:52 +0100
committerKevin Wolf <kwolf@redhat.com>2014-04-22 11:57:02 +0200
commit636ea3708c253e9d2ddac6bd7d96854ba95fb7f5 (patch)
treeb872899f275dd225b1448522e57ac20dad468d38
parentacd7fdc6d80711371d7a1507a22438d9465da63c (diff)
block: Remove -errno return value from bdrv_assign_node_name
It takes an errp argument. That's enough for error handling. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/block.c b/block.c
index 0c81747268..0ff5764cdb 100644
--- a/block.c
+++ b/block.c
@@ -788,38 +788,36 @@ static int bdrv_open_flags(BlockDriverState *bs, int flags)
return open_flags;
}
-static int bdrv_assign_node_name(BlockDriverState *bs,
- const char *node_name,
- Error **errp)
+static void bdrv_assign_node_name(BlockDriverState *bs,
+ const char *node_name,
+ Error **errp)
{
if (!node_name) {
- return 0;
+ return;
}
/* empty string node name is invalid */
if (node_name[0] == '\0') {
error_setg(errp, "Empty node name");
- return -EINVAL;
+ return;
}
/* takes care of avoiding namespaces collisions */
if (bdrv_find(node_name)) {
error_setg(errp, "node-name=%s is conflicting with a device id",
node_name);
- return -EINVAL;
+ return;
}
/* takes care of avoiding duplicates node names */
if (bdrv_find_node(node_name)) {
error_setg(errp, "Duplicate node name");
- return -EINVAL;
+ return;
}
/* copy node name into the bs and insert it into the graph list */
pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
-
- return 0;
}
/*
@@ -854,9 +852,10 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
node_name = qdict_get_try_str(options, "node-name");
- ret = bdrv_assign_node_name(bs, node_name, errp);
- if (ret < 0) {
- return ret;
+ bdrv_assign_node_name(bs, node_name, &local_err);
+ if (error_is_set(&local_err)) {
+ error_propagate(errp, local_err);
+ return -EINVAL;
}
qdict_del(options, "node-name");