diff options
| author | Christian Hopps <chopps@labn.net> | 2023-04-17 01:09:05 -0400 | 
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2023-04-17 01:43:48 -0400 | 
| commit | 9e0241c8fb9996833e7d8e104562a57276b6f906 (patch) | |
| tree | 426f77f66aa1de555aa838573d38f76e149db561 /lib/yang_wrappers.c | |
| parent | eee1fca3eb7a4ed8182f1020ef0ed13f4279c47d (diff) | |
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_wrappers.c')
| -rw-r--r-- | lib/yang_wrappers.c | 6 | 
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index 509c4dd856..dc049a374a 100644 --- a/lib/yang_wrappers.c +++ b/lib/yang_wrappers.c @@ -89,7 +89,7 @@ static const char *yang_get_default_value(const char *xpath)  	const struct lysc_node *snode;  	const char *value; -	snode = lys_find_path(ly_native_ctx, NULL, xpath, 0); +	snode = yang_find_snode(ly_native_ctx, xpath, 0);  	if (snode == NULL) {  		flog_err(EC_LIB_YANG_UNKNOWN_DATA_PATH,  			 "%s: unknown data path: %s", __func__, xpath); @@ -206,7 +206,7 @@ int yang_str2enum(const char *xpath, const char *value)  	const struct lysc_type_enum *type;  	const struct lysc_type_bitenum_item *enums; -	snode = lys_find_path(ly_native_ctx, NULL, xpath, 0); +	snode = yang_find_snode(ly_native_ctx, xpath, 0);  	if (snode == NULL) {  		flog_err(EC_LIB_YANG_UNKNOWN_DATA_PATH,  			 "%s: unknown data path: %s", __func__, xpath); @@ -241,7 +241,7 @@ struct yang_data *yang_data_new_enum(const char *xpath, int value)  	const struct lysc_type_enum *type;  	const struct lysc_type_bitenum_item *enums; -	snode = lys_find_path(ly_native_ctx, NULL, xpath, 0); +	snode = yang_find_snode(ly_native_ctx, xpath, 0);  	if (snode == NULL) {  		flog_err(EC_LIB_YANG_UNKNOWN_DATA_PATH,  			 "%s: unknown data path: %s", __func__, xpath);  | 
