@@ -5974,6 +5974,8 @@ resolve_applies_when(const struct lys_node *schema, int mode, const struct lys_n
59745974 * Logs directly.
59755975 *
59765976 * @param[in] node Data node, whose conditional reference, if such, is being decided.
5977+ * @param[in] ignore_fail 1 if when does not have to be satisfied, 2 if it does not have to be satisfied
5978+ * only when requiring external dependencies.
59775979 *
59785980 * @return
59795981 * -1 - error, ly_errno is set
@@ -5982,7 +5984,7 @@ resolve_applies_when(const struct lys_node *schema, int mode, const struct lys_n
59825984 * 1, ly_vecode = LYVE_INWHEN - nodes needed to resolve are conditional and not yet resolved (under another "when")
59835985 */
59845986int
5985- resolve_when (struct lyd_node * node , int * result , int ignore_fail )
5987+ resolve_when (struct lyd_node * node , int ignore_fail )
59865988{
59875989 struct lyd_node * ctx_node = NULL , * unlinked_nodes , * tmp_node ;
59885990 struct lys_node * sparent ;
@@ -6139,15 +6141,6 @@ resolve_when(struct lyd_node *node, int *result, int ignore_fail)
61396141cleanup :
61406142 /* free xpath set content */
61416143 lyxp_set_cast (& set , LYXP_SET_EMPTY , ctx_node ? ctx_node : node , NULL , 0 );
6142-
6143- if (result ) {
6144- if (node -> when_status & LYD_WHEN_TRUE ) {
6145- * result = 1 ;
6146- } else {
6147- * result = 0 ;
6148- }
6149- }
6150-
61516144 return rc ;
61526145}
61536146
@@ -7668,7 +7661,7 @@ resolve_unres_data_item(struct lyd_node *node, enum UNRES_ITEM type, int ignore_
76687661 return resolve_union (leaf , & sleaf -> type , 1 , ignore_fail , NULL );
76697662
76707663 case UNRES_WHEN :
7671- if ((rc = resolve_when (node , NULL , ignore_fail ))) {
7664+ if ((rc = resolve_when (node , ignore_fail ))) {
76727665 return rc ;
76737666 }
76747667 break ;
@@ -7786,7 +7779,7 @@ resolve_unres_data(struct unres_data *unres, struct lyd_node **root, int options
77867779 parent = parent -> parent ) {
77877780 if (!parent -> parent && (parent -> when_status & LYD_WHEN_FALSE )) {
77887781 /* the parent node was already unlinked, do not resolve this node,
7789- * it will be removed anyway, so just mark it as resolved
7782+ * it will be removed anyway, so just mark it as resolved
77907783 */
77917784 unres -> node [i ]-> when_status |= LYD_WHEN_FALSE ;
77927785 unres -> type [i ] = UNRES_RESOLVED ;
@@ -7800,7 +7793,10 @@ resolve_unres_data(struct unres_data *unres, struct lyd_node **root, int options
78007793
78017794 rc = resolve_unres_data_item (unres -> node [i ], unres -> type [i ], ignore_fail );
78027795 if (!rc ) {
7803- if (unres -> node [i ]-> when_status & LYD_WHEN_FALSE ) {
7796+ /* finish with error/delete the node only if when was false, an external dependency was required,
7797+ * and it was not provided (the flag would not be passed down otherwise, checked in upper fucntions) */
7798+ if ((unres -> node [i ]-> when_status & LYD_WHEN_FALSE )
7799+ && (!(unres -> node [i ]-> schema -> flags & LYS_XPATH_DEP ) || !(options & LYD_OPT_NOEXTDEPS ))) {
78047800 if ((options & LYD_OPT_NOAUTODEL ) && !unres -> node [i ]-> dflt ) {
78057801 /* false when condition */
78067802 ly_vlog_hide (0 );
0 commit comments