Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

How would I change the following code to work with libyang v4?

	/// ...
	sleaf = (const struct lysc_node_leaf *)snode;
	return sleaf->dflt ? lyd_value_get_canonical(sleaf->module->ctx, sleaf->dflt) : NULL;
You must be logged in to vote

Replies: 2 comments · 1 reply

Comment options

If you are fine with a string value, use just return sleaf->dflt;. If you require the value to be canonical, you need to generate it first using lyd_value_validate_dflt().

You must be logged in to vote
0 replies
Comment options

Ok, so

  1. is the new way to check if the schema node has a default: sleaf->dflt.str != NULL?

  2. I have code that used lyd_value_get_canonical(sleaf->module->ctx, sleaf->dflt) is there a reason I have to use lyd_value_validate_dflt() now instead of just changing to lyd_value_get_canonical(sleaf->module->ctx, &sleaf->dflt)?

  3. Also just curious, what value is present in sleaf->dflt.str? Is it whatever is present in the YANG module?

You must be logged in to vote
1 reply
@michalvasko
Comment options

  1. Yes, that is correct.
  2. The special function is for cases when the default value includes prefixes that need to be correctly canonized.
  3. Yes, it is the exact default value from the YANG module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.