schema compile REFACTOR move static function above the calling function
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 0f58d07..25d19fd 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -1484,47 +1484,6 @@
     }
 }
 
-/**
- * @brief Compile identites in a module and all its submodules.
- *
- * @param[in] mod Module to process.
- * @return LY_ERR value.
- */
-static LY_ERR
-lys_compile_identities(struct lys_module *mod)
-{
-    struct lysc_ctx ctx = {0};
-    struct lysp_submodule *submod;
-    struct lysp_module *orig_pmod = ctx->pmod;
-    LY_ARRAY_COUNT_TYPE u;
-
-    /* prepare context */
-    ctx.ctx = mod->ctx;
-    ctx.cur_mod = mod;
-    ctx.pmod = mod->parsed;
-    ctx.path_len = 1;
-    ctx.path[0] = '/';
-
-    if (mod->parsed->identities) {
-        LY_CHECK_RET(lys_compile_identities_derived(&ctx, mod->parsed->identities, &mod->identities));
-    }
-    lysc_update_path(&ctx, NULL, "{submodule}");
-    LY_ARRAY_FOR(mod->parsed->includes, u) {
-        submod = mod->parsed->includes[u].submodule;
-        if (submod->identities) {
-            ctx.pmod = (struct lysp_module *)submod;
-            lysc_update_path(&ctx, NULL, submod->name);
-            LY_CHECK_RET(lys_compile_identities_derived(&ctx, submod->identities, &mod->identities));
-            lysc_update_path(&ctx, NULL, NULL);
-        }
-    }
-    lysc_update_path(&ctx, NULL, NULL);
-
-cleanup:
-    ctx->pmod = orig_pmod;
-    return ret;
-}
-
 LY_ERR
 lys_compile(struct lys_module *mod, struct lys_glob_unres *unres)
 {
@@ -1669,6 +1628,44 @@
 }
 
 /**
+ * @brief Compile identites in a module and all its submodules.
+ *
+ * @param[in] mod Module to process.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lys_compile_identities(struct lys_module *mod)
+{
+    struct lysc_ctx ctx = {0};
+    struct lysp_submodule *submod;
+    LY_ARRAY_COUNT_TYPE u;
+
+    /* prepare context */
+    ctx.ctx = mod->ctx;
+    ctx.cur_mod = mod;
+    ctx.pmod = mod->parsed;
+    ctx.path_len = 1;
+    ctx.path[0] = '/';
+
+    if (mod->parsed->identities) {
+        LY_CHECK_RET(lys_compile_identities_derived(&ctx, mod->parsed->identities, &mod->identities));
+    }
+    lysc_update_path(&ctx, NULL, "{submodule}");
+    LY_ARRAY_FOR(mod->parsed->includes, u) {
+        submod = mod->parsed->includes[u].submodule;
+        if (submod->identities) {
+            ctx.pmod = (struct lysp_module *)submod;
+            lysc_update_path(&ctx, NULL, submod->name);
+            LY_CHECK_RET(lys_compile_identities_derived(&ctx, submod->identities, &mod->identities));
+            lysc_update_path(&ctx, NULL, NULL);
+        }
+    }
+    lysc_update_path(&ctx, NULL, NULL);
+
+    return LY_SUCCESS;
+}
+
+/**
  * @brief Check whether a module does not have any (recursive) compiled import.
  *
  * @param[in] mod Module to examine.