Skip to content

Commit

Permalink
Renamed of forgotten API
Browse files Browse the repository at this point in the history
  • Loading branch information
steweg committed Jan 18, 2024
1 parent 5d0a650 commit b92690e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/tree_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,7 @@ lyd_get_or_create_leafref_links_record(const struct lyd_node_term *node, struct
}

LIBYANG_API_DEF LY_ERR
lyd_get_term_nodes_ext_record(const struct lyd_node_term *node, struct lyd_leafref_links_rec **record)
lyd_get_leafref_links(const struct lyd_node_term *node, struct lyd_leafref_links_rec **record)
{
return lyd_get_or_create_leafref_links_record(node, record, 0);
}
Expand Down Expand Up @@ -3402,7 +3402,7 @@ lyd_unlink_leafref_node(const struct lyd_node_term *node, const struct lyd_node_
return LY_EDENIED;
}

ret = lyd_get_term_nodes_ext_record(node, &rec);
ret = lyd_get_leafref_links(node, &rec);
if (ret == LY_SUCCESS) {
LY_ARRAY_REMOVE_VALUE(rec->leafref_nodes, leafref_node);
if ((LY_ARRAY_COUNT(rec->leafref_nodes) == 0) && (rec->target_node == NULL)) {
Expand All @@ -3412,7 +3412,7 @@ lyd_unlink_leafref_node(const struct lyd_node_term *node, const struct lyd_node_
return ret;
}

ret = lyd_get_term_nodes_ext_record(leafref_node, &rec);
ret = lyd_get_leafref_links(leafref_node, &rec);
if (ret == LY_SUCCESS) {
rec->target_node = NULL;
if ((LY_ARRAY_COUNT(rec->leafref_nodes) == 0) && (rec->target_node == NULL)) {
Expand Down
6 changes: 3 additions & 3 deletions src/tree_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2718,16 +2718,16 @@ LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);

/**
* @brief Gets the term data node extension record for given node
* @brief Gets the leafref links record for given node
*
* This API requires usage of LY_CTX_LEAFREF_LINKING context flag.
*
* @param[in] node The term data node.
* @param[out] record The term data node extension record
* @param[out] record The leafref links record
* @return LY_SUCCESS on success.
* @return LY_ERR value on error.
*/
LIBYANG_API_DECL LY_ERR lyd_get_term_nodes_ext_record(const struct lyd_node_term *node, struct lyd_leafref_links_rec **record);
LIBYANG_API_DECL LY_ERR lyd_get_leafref_links(const struct lyd_node_term *node, struct lyd_leafref_links_rec **record);

/**
* @brief Traverse through data tree including root node siblings and adds leafrefs links to the given nodes
Expand Down
4 changes: 2 additions & 2 deletions src/tree_data_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ lyd_free_leafref_links_rec(struct lyd_leafref_links_rec *rec)

/* remove stored leafref nodes */
LY_ARRAY_FOR(rec->leafref_nodes, u) {
if (lyd_get_term_nodes_ext_record(rec->leafref_nodes[u], &leafref_rec) == LY_SUCCESS) {
if (lyd_get_leafref_links(rec->leafref_nodes[u], &leafref_rec) == LY_SUCCESS) {
leafref_rec->target_node = NULL;
if ((LY_ARRAY_COUNT(leafref_rec->leafref_nodes) == 0) && (leafref_rec->target_node == NULL)) {
lyd_free_leafref_nodes(rec->leafref_nodes[u]);
Expand All @@ -172,7 +172,7 @@ lyd_free_leafref_nodes(const struct lyd_node_term *node)

assert(node);

if (lyd_get_term_nodes_ext_record(node, &rec) != LY_SUCCESS) {
if (lyd_get_leafref_links(node, &rec) != LY_SUCCESS) {
return;
}

Expand Down
28 changes: 14 additions & 14 deletions tests/utests/data/test_tree_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,36 +649,36 @@ test_data_leafref_nodes(void **state)
}

/* verify state after leafref plugin validation */
assert_int_equal(LY_SUCCESS, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(1, LY_ARRAY_COUNT(rec->leafref_nodes));
assert_int_equal(LY_SUCCESS, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_get_leafref_links(leafref_node, &rec));
assert_ptr_equal(rec->target_node, target_node);
/* value modification of target */
assert_int_equal(LY_SUCCESS, lyd_change_term((struct lyd_node *)target_node, "ASD"));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(leafref_node, &rec));
/* change back to original value */
assert_int_equal(LY_SUCCESS, lyd_change_term((struct lyd_node *)target_node, "asd"));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(leafref_node, &rec));
/* linking the whole tree again */
assert_int_equal(LY_SUCCESS, lyd_link_leafref_node_tree(tree));
assert_int_equal(LY_SUCCESS, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(1, LY_ARRAY_COUNT(rec->leafref_nodes));
assert_int_equal(LY_SUCCESS, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_get_leafref_links(leafref_node, &rec));
assert_ptr_equal(rec->target_node, target_node);
/* value modification of leafref */
assert_int_equal(LY_SUCCESS, lyd_change_term((struct lyd_node *)leafref_node, "qwe"));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(leafref_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_change_term((struct lyd_node *)leafref_node, "asd"));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(LY_ENOTFOUND, lyd_get_leafref_links(leafref_node, &rec));
/* linking the whole tree again */
assert_int_equal(LY_SUCCESS, lyd_link_leafref_node_tree(tree));
assert_int_equal(LY_SUCCESS, lyd_get_term_nodes_ext_record(target_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_get_leafref_links(target_node, &rec));
assert_int_equal(1, LY_ARRAY_COUNT(rec->leafref_nodes));
assert_int_equal(LY_SUCCESS, lyd_get_term_nodes_ext_record(leafref_node, &rec));
assert_int_equal(LY_SUCCESS, lyd_get_leafref_links(leafref_node, &rec));
assert_ptr_equal(rec->target_node, target_node);
/* freeing whole tree */
lyd_free_all(tree);
Expand Down

0 comments on commit b92690e

Please sign in to comment.