summaryrefslogtreecommitdiff
path: root/lib/northbound_oper.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/northbound_oper.c')
-rw-r--r--lib/northbound_oper.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/northbound_oper.c b/lib/northbound_oper.c
index 0364870486..c80cdc116a 100644
--- a/lib/northbound_oper.c
+++ b/lib/northbound_oper.c
@@ -1561,17 +1561,13 @@ static void nb_op_walk_continue(struct event *thread)
ret = __walk(ys, true);
if (ret == NB_YIELD) {
- if (nb_op_yield(ys) != NB_OK) {
- if (ys->should_batch)
- goto stopped;
- else
- goto finish;
- }
- return;
+ ret = nb_op_yield(ys);
+ if (ret == NB_OK)
+ return;
}
finish:
+ assert(ret != NB_YIELD);
(*ys->finish)(ys_root_node(ys), ys->finish_arg, ret);
-stopped:
nb_op_free_yield_state(ys, false);
}
@@ -1630,6 +1626,13 @@ static void nb_op_trim_yield_state(struct nb_op_yield_state *ys)
(int)darr_lasti(ys->node_infos));
}
+/**
+ * nb_op_yield() - Yield during the walk.
+ * @ys: the yield state tracking the walk.
+ *
+ * Return: Any error from the `ys->finish` callback which should terminate the
+ * walk. Otherwise if `ys->should_batch` == false always returns NB_OK.
+ */
static enum nb_error nb_op_yield(struct nb_op_yield_state *ys)
{
enum nb_error ret;
@@ -1842,17 +1845,13 @@ void *nb_oper_walk(const char *xpath, struct yang_translator *translator,
ret = nb_op_walk_start(ys);
if (ret == NB_YIELD) {
- if (nb_op_yield(ys) != NB_OK) {
- if (ys->should_batch)
- goto stopped;
- else
- goto finish;
- }
- return ys;
+ ret = nb_op_yield(ys);
+ if (ret == NB_OK)
+ return ys;
}
-finish:
+
+ assert(ret != NB_YIELD);
(void)(*ys->finish)(ys_root_node(ys), ys->finish_arg, ret);
-stopped:
nb_op_free_yield_state(ys, false);
return NULL;
}