tree DOC minor improvements
diff --git a/src/tree_data.h b/src/tree_data.h
index 06ee812..0849197 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -980,8 +980,10 @@
/**
* @brief Get the (canonical) value of a lyd_value.
*
+ * Whenever possible, ::lyd_get_value() or ::lyd_get_meta_value() should be used instead.
+ *
* @param[in] ctx Context for the value
- * @param[in] value value node to use.
+ * @param[in] value Value structure to use.
* @return Canonical value.
*/
const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
@@ -1003,10 +1005,9 @@
return ((struct lyd_node_opaq *)node)->value;
} else if (node->schema->nodetype & LYD_NODE_TERM) {
const struct lyd_value *value = &((struct lyd_node_term *)node)->value;
- return value->_canonical
- ? value->_canonical
- : lyd_value_get_canonical(LYD_CTX(node), value);
+ return value->_canonical ? value->_canonical : lyd_value_get_canonical(LYD_CTX(node), value);
}
+
return NULL;
}
@@ -1021,10 +1022,9 @@
{
if (meta) {
const struct lyd_value *value = &meta->value;
- return value->_canonical
- ? value->_canonical
- : lyd_value_get_canonical(meta->annotation->module->ctx, value);
+ return value->_canonical ? value->_canonical : lyd_value_get_canonical(meta->annotation->module->ctx, value);
}
+
return NULL;
}
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 4ae8b3f..e1eadf8 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -259,10 +259,8 @@
API const char *
lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value)
{
- return value->_canonical
- ? value->_canonical
- : (const char *)value->realtype->plugin->print(
- ctx, value, LY_VALUE_CANON, NULL, NULL, NULL);
+ return value->_canonical ? value->_canonical :
+ (const char *)value->realtype->plugin->print(ctx, value, LY_VALUE_CANON, NULL, NULL, NULL);
}
API LY_ERR
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 5393621..b5eea87 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -1851,7 +1851,7 @@
struct lysc_type *type; /**< type of the leaf node (mandatory) */
const char *units; /**< units of the leaf's type */
- struct lyd_value *dflt; /**< default value */
+ struct lyd_value *dflt; /**< default value, use ::lyd_value_get_canonical() to get the canonical string */
};
struct lysc_node_leaflist {
@@ -1881,7 +1881,8 @@
struct lysc_type *type; /**< type of the leaf node (mandatory) */
const char *units; /**< units of the leaf's type */
- struct lyd_value **dflts; /**< list ([sized array](@ref sizedarrays)) of default values */
+ struct lyd_value **dflts; /**< list ([sized array](@ref sizedarrays)) of default values, use
+ ::lyd_value_get_canonical() to get the canonical strings */
uint32_t min; /**< min-elements constraint */
uint32_t max; /**< max-elements constraint */