summaryrefslogtreecommitdiffstats
path: root/lib/yang_translator.c
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-04-17 07:09:05 +0200
committerChristian Hopps <chopps@labn.net>2023-04-17 07:43:48 +0200
commit9e0241c8fb9996833e7d8e104562a57276b6f906 (patch)
tree426f77f66aa1de555aa838573d38f76e149db561 /lib/yang_translator.c
parentMerge pull request #13141 from mjstapp/fix_ospf_json_keys (diff)
downloadfrr-9e0241c8fb9996833e7d8e104562a57276b6f906.tar.xz
frr-9e0241c8fb9996833e7d8e104562a57276b6f906.zip
lib: add and use new yang function for finding schema nodes
Add a wrapper around lys_find_xpath which has an unfortunate API returning an allocated set of schema nodes when we only ever expect and want one. Another libyang function `lys_find_path` returns a single node; however, that function can assert/abort on invalid path values so is unsuitable for user input. Replace previous uses of `lys_find_path` with new API when dealing with possible invalid path values (i.e., from a user). Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/yang_translator.c')
-rw-r--r--lib/yang_translator.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/yang_translator.c b/lib/yang_translator.c
index de668230a..eae7577a0 100644
--- a/lib/yang_translator.c
+++ b/lib/yang_translator.c
@@ -235,8 +235,8 @@ struct yang_translator *yang_translator_load(const char *path)
xpath_custom =
yang_dnode_get_string(set->dnodes[i], "./custom");
- snode_custom = lys_find_path(translator->ly_ctx, NULL,
- xpath_custom, 0);
+ snode_custom =
+ yang_find_snode(translator->ly_ctx, xpath_custom, 0);
if (!snode_custom) {
flog_warn(EC_LIB_YANG_TRANSLATOR_LOAD,
"%s: unknown data path: %s", __func__,
@@ -247,8 +247,7 @@ struct yang_translator *yang_translator_load(const char *path)
xpath_native =
yang_dnode_get_string(set->dnodes[i], "./native");
- snode_native =
- lys_find_path(ly_native_ctx, NULL, xpath_native, 0);
+ snode_native = yang_find_snode(ly_native_ctx, xpath_native, 0);
if (!snode_native) {
flog_warn(EC_LIB_YANG_TRANSLATOR_LOAD,
"%s: unknown data path: %s", __func__,
@@ -315,7 +314,7 @@ yang_translate_xpath(const struct yang_translator *translator, int dir,
else
ly_ctx = ly_native_ctx;
- snode = lys_find_path(ly_ctx, NULL, xpath, 0);
+ snode = yang_find_snode(ly_ctx, xpath, 0);
if (!snode) {
flog_warn(EC_LIB_YANG_TRANSLATION_ERROR,
"%s: unknown data path: %s", __func__, xpath);