tree schema CHANGE flags LYS_MODS_LATEST_*
If ::LYS_MOD_LATEST_SEARCHDIRS is set, then ::LYS_MOD_LATEST_REV must
be set too.
diff --git a/src/context.c b/src/context.c
index f45be51..328de40 100644
--- a/src/context.c
+++ b/src/context.c
@@ -761,7 +761,7 @@
uint32_t index = 0;
while ((mod = ly_ctx_get_module_by_iter(ctx, key, 0, key_offset, &index))) {
- if (mod->latest_revision & (LYS_MOD_LATEST_REV | LYS_MOD_LATEST_SEARCHDIRS)) {
+ if (mod->latest_revision & LYS_MOD_LATEST_REV) {
return mod;
}
}
@@ -930,13 +930,13 @@
mod = ctx->list.objs[v];
if (mod->latest_revision & LYS_MOD_LATEST_SEARCHDIRS) {
mod->latest_revision &= ~LYS_MOD_LATEST_SEARCHDIRS;
- mod->latest_revision |= LYS_MOD_LATEST_REV;
+ assert(mod->latest_revision & LYS_MOD_LATEST_REV);
}
if (mod->parsed && mod->parsed->includes) {
for (LY_ARRAY_COUNT_TYPE u = 0; u < LY_ARRAY_COUNT(mod->parsed->includes); ++u) {
if (mod->parsed->includes[u].submodule->latest_revision & LYS_MOD_LATEST_SEARCHDIRS) {
mod->parsed->includes[u].submodule->latest_revision &= ~LYS_MOD_LATEST_SEARCHDIRS;
- mod->parsed->includes[u].submodule->latest_revision |= LYS_MOD_LATEST_REV;
+ assert(mod->latest_revision & LYS_MOD_LATEST_REV);
}
}
}
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 40fd706..3282db3 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -2331,9 +2331,8 @@
*
* @{
*/
-#define LYS_MOD_LATEST_REV 0x01 /**< The latest revision in searchdirs was not searched yet
- and this is the latest revision in the current context. */
-#define LYS_MOD_LATEST_SEARCHDIRS 0x02 /**< Searchdirs were searched and this is the latest available revision. */
+#define LYS_MOD_LATEST_REV 0x01 /**< This is the latest revision of the module in the current context. */
+#define LYS_MOD_LATEST_SEARCHDIRS 0x02 /**< This is the latest revision of the module found in searchdirs. */
/** @} latestrevflags */
/**
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 785d187..8ef2a4e 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -828,7 +828,7 @@
} else {
/* get the requested module of the latest revision in the context */
*mod = ly_ctx_get_module_latest(ctx, name);
- if (*mod && ((*mod)->latest_revision & LYS_MOD_LATEST_REV)) {
+ if (*mod) {
/* let us now search with callback and searchpaths to check if there is newer revision outside the context */
ctx_latest = *mod;
*mod = NULL;
@@ -880,11 +880,10 @@
if (!*mod && ctx_latest) {
LOGVRB("Newer revision than \"%s@%s\" not found, using this as the latest revision.", ctx_latest->name,
ctx_latest->revision);
- ctx_latest->latest_revision &= ~LYS_MOD_LATEST_REV;
+ assert(ctx_latest->latest_revision & LYS_MOD_LATEST_REV);
ctx_latest->latest_revision |= LYS_MOD_LATEST_SEARCHDIRS;
*mod = ctx_latest;
} else if (*mod && !revision && ((*mod)->latest_revision & LYS_MOD_LATEST_REV)) {
- (*mod)->latest_revision &= ~LYS_MOD_LATEST_REV;
(*mod)->latest_revision |= LYS_MOD_LATEST_SEARCHDIRS;
}