Kevin Wolf <kw...@redhat.com> writes: > It takes an errp argument. That's enough for error handling. > > Signed-off-by: Kevin Wolf <kw...@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");
Please use 'if (local_err)' instead of 'if (error_is_set(&local_err))'. See commit 84d18f0. I don't like functions returning their only value through a pointer rather than the function value, but I guess it's how Error wants to be used.