libyang REFACTOR return values and options changes

Unified, all functions that return a variety
of errors return LY_ERR. Any options such as
NOSIBLINGS, WITHSIBLINGS and so on were replaced
by function variants with suffixes _single, _all,
_tree, and _siblings.
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index e079640..bedf795 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -755,34 +755,42 @@
 
     LY_CHECK_RET(lys_search_localfile(ly_ctx_get_searchdirs(ctx), !(ctx->flags & LY_CTX_DISABLE_SEARCHDIR_CWD), name, revision,
                                       &filepath, &format));
-    LY_CHECK_ERR_RET(!filepath, if (required) {LOGERR(ctx, LY_ENOTFOUND, "Data model \"%s%s%s\" not found in local searchdirs.",
-                                       name, revision ? "@" : "", revision ? revision : "");}, LY_ENOTFOUND);
+    if (!filepath) {
+        if (required) {
+            LOGERR(ctx, LY_ENOTFOUND, "Data model \"%s%s%s\" not found in local searchdirs.", name, revision ? "@" : "",
+                   revision ? revision : "");
+        }
+        return LY_ENOTFOUND;
+    }
 
     LOGVRB("Loading schema from \"%s\" file.", filepath);
 
     /* get the (sub)module */
-    LY_CHECK_ERR_GOTO(ret = ly_in_new_filepath(filepath, 0, &in), LOGERR(ctx, ret, "Unable to create input handler for filepath %s.", filepath), cleanup);
+    LY_CHECK_ERR_GOTO(ret = ly_in_new_filepath(filepath, 0, &in),
+                      LOGERR(ctx, ret, "Unable to create input handler for filepath %s.", filepath), cleanup);
     check_data.name = name;
     check_data.revision = revision;
     check_data.path = filepath;
     check_data.submoduleof = main_name;
     if (main_ctx) {
-        mod = lys_parse_mem_submodule(ctx, in, format, main_ctx, lysp_load_module_check, &check_data);
+        ret = lys_parse_mem_submodule(ctx, in, format, main_ctx, lysp_load_module_check, &check_data,
+                                      (struct lysp_submodule **)&mod);
     } else {
-        mod = lys_parse_mem_module(ctx, in, format, implement, lysp_load_module_check, &check_data);
+        ret = lys_parse_mem_module(ctx, in, format, implement, lysp_load_module_check, &check_data,
+                                   (struct lys_module **)&mod);
 
     }
-    LY_CHECK_ERR_GOTO(!mod, ly_in_free(in, 1);ly_errcode(ctx), cleanup);
+    LY_CHECK_ERR_GOTO(ret, ly_in_free(in, 1), cleanup);
 
     if (main_ctx) {
-        lys_parser_fill_filepath(ctx, in, &((struct lysp_submodule*)mod)->filepath);
+        lys_parser_fill_filepath(ctx, in, &((struct lysp_submodule *)mod)->filepath);
     } else {
-        lys_parser_fill_filepath(ctx, in, &((struct lys_module*)mod)->filepath);
+        lys_parser_fill_filepath(ctx, in, &((struct lys_module *)mod)->filepath);
     }
     ly_in_free(in, 1);
 
     if (mod && implement) {
-        lys_compile((struct lys_module**)&mod, 0);
+        lys_compile((struct lys_module **)&mod, 0);
     }
 
     *result = mod;
@@ -794,7 +802,8 @@
 }
 
 LY_ERR
-lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, int implement, int require_parsed, struct lys_module **mod)
+lysp_load_module(struct ly_ctx *ctx, const char *name, const char *revision, int implement, int require_parsed,
+                 struct lys_module **mod)
 {
     const char *module_data = NULL;
     LYS_INFORMAT format = LYS_IN_UNKNOWN;
@@ -848,7 +857,7 @@
                     LY_CHECK_RET(ly_in_new_memory(module_data, &in));
                     check_data.name = name;
                     check_data.revision = revision;
-                    *mod = lys_parse_mem_module(ctx, in, format, implement, lysp_load_module_check, &check_data);
+                    lys_parse_mem_module(ctx, in, format, implement, lysp_load_module_check, &check_data, mod);
                     ly_in_free(in, 0);
                     if (module_data_free) {
                         module_data_free((void*)module_data, ctx->imp_clb_data);
@@ -970,7 +979,7 @@
                 check_data.name = inc->name;
                 check_data.revision = inc->rev[0] ? inc->rev : NULL;
                 check_data.submoduleof = mod->mod->name;
-                submod = lys_parse_mem_submodule(ctx, in, format, pctx, lysp_load_module_check, &check_data);
+                lys_parse_mem_submodule(ctx, in, format, pctx, lysp_load_module_check, &check_data, &submod);
                 ly_in_free(in, 0);
                 if (submodule_data_free) {
                     submodule_data_free((void*)submodule_data, ctx->imp_clb_data);