From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH] block: Remove -errno return value from bdrv_assign_node_name
Date: Tue, 18 Mar 2014 10:00:19 +0100 [thread overview]
Message-ID: <1395133219-8009-1-git-send-email-kwolf@redhat.com> (raw)
It takes an errp argument. That's enough for error handling.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/block.c b/block.c
index acb70fd..b4f3f77 100644
--- a/block.c
+++ b/block.c
@@ -783,18 +783,18 @@ 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 */
@@ -807,14 +807,12 @@ static int bdrv_assign_node_name(BlockDriverState *bs,
/* 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;
}
/*
@@ -849,9 +847,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");
--
1.8.3.1
next reply other threads:[~2014-03-18 9:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 9:00 Kevin Wolf [this message]
2014-03-18 10:09 ` [Qemu-devel] [PATCH] block: Remove -errno return value from bdrv_assign_node_name Markus Armbruster
2014-03-18 10:54 ` Kevin Wolf
2014-03-18 12:03 ` Markus Armbruster
2014-03-18 15:50 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395133219-8009-1-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).