diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2018-11-25 14:41:38 -0200 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-11-26 15:53:15 -0200 |
| commit | 25c780a32a0de196688b3f08e82e6a56d7b49b2f (patch) | |
| tree | dd5b8b0e087a70b21d6472140d5688791efae177 /lib/yang.c | |
| parent | 3f662078965405c6363dcecc2cc43c658c108229 (diff) | |
lib: make yang_dnode_get_entry() more flexible
Add the "abort_if_not_found" parameter to the yang_dnode_get_entry()
function instead of always aborting when an user pointer is not
found. This will make it possible, for example, to use this function
during the validation phase of a configuration transaction. Callers
will only need to check if the function returned NULL or not,
since new configuration objects (if any) won't be created until
the NB_EV_APPLY phase of the transaction.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/yang.c')
| -rw-r--r-- | lib/yang.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/yang.c b/lib/yang.c index f41c645758..757982d367 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -493,7 +493,8 @@ void yang_dnode_set_entry(const struct lyd_node *dnode, void *entry) lyd_set_private(dnode, entry); } -void *yang_dnode_get_entry(const struct lyd_node *dnode) +void *yang_dnode_get_entry(const struct lyd_node *dnode, + bool abort_if_not_found) { const struct lyd_node *orig_dnode = dnode; char xpath[XPATH_MAXLEN]; @@ -512,6 +513,9 @@ void *yang_dnode_get_entry(const struct lyd_node *dnode) dnode = dnode->parent; } + if (!abort_if_not_found) + return NULL; + yang_dnode_get_path(orig_dnode, xpath, sizeof(xpath)); flog_err(EC_LIB_YANG_DNODE_NOT_FOUND, "%s: failed to find entry [xpath %s]", __func__, xpath); |
