schema mount REFACTOR minor improvements
diff --git a/src/plugins_exts/schema_mount.c b/src/plugins_exts/schema_mount.c
index 6a3c86e..c768b5f 100644
--- a/src/plugins_exts/schema_mount.c
+++ b/src/plugins_exts/schema_mount.c
@@ -238,7 +238,7 @@
* @param[in] ext Compiled extension instance.
* @param[in] ext_data Extension data retrieved by the callback.
* @param[out] config Whether the whole schema should keep its config or be set to false.
- * @param[out] shared Whether the schema is shared or inline.
+ * @param[out] shared Optional flag whether the schema is shared or inline.
* @return LY_ERR value.
*/
static LY_ERR
@@ -271,14 +271,16 @@
*config = 0;
}
- /* check schema-ref */
- if (lyd_find_path(mpoint, "shared-schema", 0, NULL)) {
- if (lyd_find_path(mpoint, "inline", 0, NULL)) {
- EXT_LOGERR_INT_RET(NULL, ext);
+ if (shared) {
+ /* check schema-ref */
+ if (lyd_find_path(mpoint, "shared-schema", 0, NULL)) {
+ if (lyd_find_path(mpoint, "inline", 0, NULL)) {
+ EXT_LOGERR_INT_RET(NULL, ext);
+ }
+ *shared = 0;
+ } else {
+ *shared = 1;
}
- *shared = 0;
- } else {
- *shared = 1;
}
return LY_SUCCESS;
@@ -922,38 +924,36 @@
LIBYANG_API_DEF LY_ERR
lyplg_ext_schema_mount_create_context(const struct lysc_ext_instance *ext, struct ly_ctx **ctx)
{
- struct lyd_node *ext_data;
- ly_bool ext_data_free;
- ly_bool config;
- ly_bool shared;
- LY_ERR res;
+ struct lyd_node *ext_data = NULL;
+ ly_bool ext_data_free = 0, config;
+ LY_ERR rc = LY_SUCCESS;
if (!ext->module->ctx->ext_clb) {
return LY_EINVAL;
}
- if (strcmp(ext->def->module->name, "ietf-yang-schema-mount") ||
- strcmp(ext->def->name, "mount-point")) {
+ if (strcmp(ext->def->module->name, "ietf-yang-schema-mount") || strcmp(ext->def->name, "mount-point")) {
return LY_EINVAL;
}
/* get operational data with ietf-yang-library and ietf-yang-schema-mount data */
- if ((res = lyplg_ext_get_data(ext->module->ctx, ext, (void **)&ext_data, &ext_data_free))) {
- return res;
+ if ((rc = lyplg_ext_get_data(ext->module->ctx, ext, (void **)&ext_data, &ext_data_free))) {
+ return rc;
}
/* learn about this mount point */
- if ((res = schema_mount_get_smount(ext, ext_data, &config, &shared))) {
- goto out;
+ if ((rc = schema_mount_get_smount(ext, ext_data, &config, NULL))) {
+ goto cleanup;
}
- res = schema_mount_create_ctx(ext, ext_data, config, ctx);
+ /* create the context */
+ rc = schema_mount_create_ctx(ext, ext_data, config, ctx);
-out:
+cleanup:
if (ext_data_free) {
lyd_free_all(ext_data);
}
- return res;
+ return rc;
}
static void
@@ -1027,6 +1027,11 @@
return LY_SUCCESS;
}
+/**
+ * @brief Schema mount schema parsed tree printer.
+ *
+ * Implementation of ::lyplg_ext_sprinter_ptree_clb callback set as lyext_plugin::printer_ptree.
+ */
static LY_ERR
schema_mount_sprinter_ptree(struct lysp_ext_instance *UNUSED(ext), const struct lyspr_tree_ctx *ctx,
const char **flags, const char **UNUSED(add_opts))
@@ -1038,6 +1043,11 @@
return LY_SUCCESS;
}
+/**
+ * @brief Schema mount schema compiled tree printer.
+ *
+ * Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
+ */
static LY_ERR
schema_mount_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **flags, const char **UNUSED(add_opts))