Skip to content

Commit fbd7431

Browse files
authored
Merge pull request FRRouting#16764 from LabNConsulting/chopps/fix-clang-sa-warning
lib: fix clang SA warnings
2 parents 80d3a2b + 0358437 commit fbd7431

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

lib/northbound_oper.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -751,30 +751,30 @@ static const struct lysc_node *nb_op_sib_next(struct nb_op_yield_state *ys,
751751

752752
/*
753753
* If the node info stack is shorter than the schema path then we are
754-
* doign specific query still on the node from the schema path (should
755-
* match) so just return NULL (i.e., don't process siblings)
754+
* working our way down the specific query path so just return NULL
755+
* (i.e., don't process siblings)
756756
*/
757757
if (darr_len(ys->schema_path) > darr_len(ys->node_infos))
758758
return NULL;
759759
/*
760760
* If sib is on top of the node info stack then
761761
* 1) it's a container node -or-
762762
* 2) it's a list node that we were walking and we've reach the last entry
763-
* 3) if sib is a list and the list was empty we never would have
763+
*
764+
* If sib is a list and the list was empty we never would have
764765
* pushed sib on the stack so the top of the stack is the parent
765766
*
766767
* If the query string included this node then we do not process any
767768
* siblings as we are not walking all the parent's children just this
768769
* specified one give by the query string.
769770
*/
770-
if (sib == darr_last(ys->node_infos)->schema &&
771-
darr_len(ys->schema_path) >= darr_len(ys->node_infos))
772-
return NULL;
773-
/* case (3) */
774-
else if (sib->nodetype == LYS_LIST &&
775-
parent == darr_last(ys->node_infos)->schema &&
776-
darr_len(ys->schema_path) > darr_len(ys->node_infos))
777-
return NULL;
771+
if (darr_len(ys->schema_path) == darr_len(ys->node_infos)) {
772+
struct nb_op_node_info *node_infos = darr_last(ys->node_infos);
773+
774+
assert(node_infos);
775+
if (sib == node_infos->schema)
776+
return NULL;
777+
}
778778

779779
sib = __sib_next(yn, sib->next);
780780
if (sib)
@@ -801,6 +801,7 @@ static const struct lysc_node *nb_op_sib_first(struct nb_op_yield_state *ys,
801801
{
802802
const struct lysc_node *sib = lysc_node_child(parent);
803803
const struct lysc_node *first_sib;
804+
struct nb_op_node_info *last = darr_last(ys->node_infos);
804805

805806
/*
806807
* NOTE: when we want to handle root level walks we will need to use
@@ -817,10 +818,9 @@ static const struct lysc_node *nb_op_sib_first(struct nb_op_yield_state *ys,
817818
* base of the user query, return the next schema node from the query
818819
* string (schema_path).
819820
*/
820-
if (darr_last(ys->node_infos) != NULL &&
821-
!CHECK_FLAG(darr_last(ys->node_infos)->schema->nodetype,
822-
LYS_CASE | LYS_CHOICE))
823-
assert(darr_last(ys->node_infos)->schema == parent);
821+
if (last != NULL &&
822+
!CHECK_FLAG(last->schema->nodetype, LYS_CASE | LYS_CHOICE))
823+
assert(last->schema == parent);
824824
if (darr_lasti(ys->node_infos) < ys->query_base_level)
825825
return ys->schema_path[darr_lasti(ys->node_infos) + 1];
826826

@@ -908,9 +908,10 @@ static enum nb_error __walk(struct nb_op_yield_state *ys, bool is_resume)
908908
* Otherwise get the first child of the container we are walking,
909909
* starting with non-yielding children.
910910
*/
911-
if (is_resume)
911+
if (is_resume) {
912+
assert(darr_last(ys->node_infos) != NULL);
912913
sib = darr_last(ys->node_infos)->schema;
913-
else {
914+
} else {
914915
/*
915916
* Start with non-yielding children first.
916917
*
@@ -1477,7 +1478,8 @@ static void nb_op_walk_continue(struct event *thread)
14771478
goto finish;
14781479

14791480
/* otherwise we are at a resumable node */
1480-
assert(darr_last(ys->node_infos)->has_lookup_next);
1481+
assert(darr_last(ys->node_infos) &&
1482+
darr_last(ys->node_infos)->has_lookup_next);
14811483

14821484
ret = __walk(ys, true);
14831485
if (ret == NB_YIELD) {

0 commit comments

Comments
 (0)