Skip to content

Commit 116f06d

Browse files
committed
tree data REVERT do not allow creating more opaque nodes
Would need many additional restrictions and seems to be a redundant feature. Reverts 4426310
1 parent 5665973 commit 116f06d

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/tree_data.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,10 @@ LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, c
12951295
default flag is changed, it is returned. If the target node exists and is not
12961296
a leaf or generally no change occurs in the @p parent tree, NULL is returned and
12971297
no error set. */
1298-
#define LYD_NEW_PATH_OPAQ 0x40 /**< Enables the creation of opaque nodes with some specific rules. If a node in
1299-
the path is not uniquely defined ((leaf-)list without a predicate) or has an
1300-
invalid value (leaf/leaf-list), it is created as opaque. Otherwise a regular
1301-
node is created. */
1298+
#define LYD_NEW_PATH_OPAQ 0x40 /**< Enables the creation of opaque nodes with some specific rules. If the __last node__
1299+
in the path is not uniquely defined ((leaf-)list without a predicate) or has an
1300+
invalid value (leaf/leaf-list), it is created as opaque. Otherwise a regular node
1301+
is created. */
13021302
#define LYD_NEW_PATH_WITH_OPAQ 0x80 /**< Consider opaque nodes normally when searching for existing nodes. */
13031303
#define LYD_NEW_ANY_USE_VALUE 0x100 /**< Whether to use dynamic @p value or make a copy. */
13041304

src/tree_data_new.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ lyd_new_path_check_find_lypath(struct ly_path *path, const char *str_path, const
15881588
}
15891589
} else if ((schema->nodetype == LYS_LIST) &&
15901590
(!path[u].predicates || (path[u].predicates[0].type != LY_PATH_PREDTYPE_LIST))) {
1591-
if (!(options & LYD_NEW_PATH_OPAQ)) {
1591+
if ((u < LY_ARRAY_COUNT(path) - 1) || !(options & LYD_NEW_PATH_OPAQ)) {
15921592
LOG_LOCSET(schema, NULL);
15931593
LOGVAL(schema->module->ctx, LYVE_XPATH, "Predicate missing for %s \"%s\" in path \"%s\".",
15941594
lys_nodetype2str(schema->nodetype), schema->name, str_path);

tests/utests/data/test_new.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,6 @@ test_path(void **state)
319319

320320
lyd_free_tree(root);
321321

322-
ret = lyd_new_path(NULL, UTEST_LYCTX, "/a:l1/c", NULL, LYD_NEW_PATH_OPAQ, &root);
323-
assert_int_equal(ret, LY_SUCCESS);
324-
assert_null(root->schema);
325-
assert_null(lyd_child(root)->schema);
326-
327-
lyd_free_tree(root);
328-
329322
/* key-less list */
330323
ret = lyd_new_path2(NULL, UTEST_LYCTX, "/a:c2/l3/x", "val1", 0, 0, 0, &root, &node);
331324
assert_int_equal(ret, LY_SUCCESS);

0 commit comments

Comments
 (0)