types CHANGE unify return error code when validating type and the value

reserve LY_EINVAL for invalid function parameter and use LY_EVALID for
validation errors.
diff --git a/src/path.c b/src/path.c
index c620b86..0d5f3f3 100644
--- a/src/path.c
+++ b/src/path.c
@@ -274,7 +274,7 @@
 
 error:
     lyxp_expr_free(ctx, exp);
-    return LY_EINVAL;
+    return LY_EVALID;
 }
 
 LY_ERR
@@ -306,7 +306,7 @@
 
 error:
     lyxp_expr_free(ctx, exp);
-    return LY_EINVAL;
+    return LY_EVALID;
 }
 
 /**
@@ -346,11 +346,11 @@
         if (!*mod) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Prefix \"%.*s\" not found of a module in path.",
                    len, expr->expr + expr->tok_pos[tok_idx]);
-            return LY_EINVAL;
+            return LY_EVALID;
         } else if (!(*mod)->implemented) {
             if (lref == LY_PATH_LREF_FALSE) {
                 LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Not implemented module \"%s\" in path.", (*mod)->name);
-                return LY_EINVAL;
+                return LY_EVALID;
             }
             lys_set_implemented_internal((struct lys_module *)*mod, 2);
         }
@@ -410,11 +410,11 @@
         if (ctx_node->nodetype != LYS_LIST) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "List predicate defined for %s \"%s\" in path.",
                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         } else if (ctx_node->flags & LYS_KEYLESS) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "List predicate defined for keyless %s \"%s\" in path.",
                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         }
 
         do {
@@ -424,11 +424,11 @@
             key = lys_find_child(ctx_node, mod, name, name_len, 0, LYS_GETNEXT_NOSTATECHECK);
             if (!key) {
                 LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Not found node \"%.*s\" in path.", name_len, name);
-                return LY_EINVAL;
+                return LY_EVALID;
             } else if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
                 LOGVAL(ctx, LY_VLOG_LYSC, key, LYVE_XPATH, "Key expected instead of %s \"%s\" in path.",
                        lys_nodetype2str(key->nodetype), key->name);
-                return LY_EINVAL;
+                return LY_EVALID;
             }
             ++(*tok_idx);
 
@@ -468,14 +468,14 @@
                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             ly_path_predicates_free(ctx, LY_PATH_PREDTYPE_LIST, NULL, *predicates);
             *predicates = NULL;
-            return LY_EINVAL;
+            return LY_EVALID;
         }
 
     } else if (expr->tokens[*tok_idx] == LYXP_TOKEN_DOT) {
         if (ctx_node->nodetype != LYS_LEAFLIST) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Leaf-list predicate defined for %s \"%s\" in path.",
                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         }
         ++(*tok_idx);
 
@@ -501,11 +501,11 @@
         if (!(ctx_node->nodetype & (LYS_LEAFLIST | LYS_LIST))) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Positional predicate defined for %s \"%s\" in path.",
                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         } else if (ctx_node->flags & LYS_CONFIG_W) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Positional predicate defined for configuration"
                    " %s \"%s\" in path.", lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         }
 
         /* new predicate */
@@ -555,11 +555,11 @@
     if (ctx_node->nodetype != LYS_LIST) {
         LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "List predicate defined for %s \"%s\" in path.",
                lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-        return LY_EINVAL;
+        return LY_EVALID;
     } else if (ctx_node->flags & LYS_KEYLESS) {
         LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "List predicate defined for keyless %s \"%s\" in path.",
                lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
-        return LY_EINVAL;
+        return LY_EVALID;
     }
 
     do {
@@ -569,11 +569,11 @@
         key = lys_find_child(ctx_node, mod, name, name_len, 0, LYS_GETNEXT_NOSTATECHECK);
         if (!key) {
             LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Not found node \"%.*s\" in path.", name_len, name);
-            return LY_EINVAL;
+            return LY_EVALID;
         } else if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
             LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Key expected instead of %s \"%s\" in path.",
                    lys_nodetype2str(key->nodetype), key->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         }
         ++(*tok_idx);
 
@@ -607,7 +607,7 @@
             /* go to parent */
             if (!node) {
                 LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Too many parent references in path.");
-                return LY_EINVAL;
+                return LY_EVALID;
             }
             node = lysc_data_parent(node);
 
@@ -629,7 +629,7 @@
             if (!node2) {
                 LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Not found node \"%.*s\" in path.",
                        name_len, name);
-                return LY_EINVAL;
+                return LY_EVALID;
             }
             node = node2;
             ++(*tok_idx);
@@ -639,7 +639,7 @@
         if (node->nodetype != LYS_LEAF) {
             LOGVAL(cur_node->module->ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Leaf expected instead of %s \"%s\" in"
                    " leafref predicate in path.", lys_nodetype2str(node->nodetype), node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         }
 
         /* we are not actually compiling, throw the rightside node away */
@@ -697,7 +697,7 @@
         while ((lref == LY_PATH_LREF_TRUE) && (expr->tokens[tok_idx] == LYXP_TOKEN_DDOT)) {
             if (!ctx_node) {
                 LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Too many parent references in path.");
-                return LY_EINVAL;
+                return LY_EVALID;
             }
 
             /* get parent */
@@ -718,7 +718,7 @@
         if (p && (lref == LY_PATH_LREF_FALSE) && (p->node->nodetype == LYS_LIST) && !p->predicates) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
                    lys_nodetype2str(p->node->nodetype), p->node->name);
-            return LY_EINVAL;
+            return LY_EVALID;
         }
 
         /* get module and node name */
@@ -730,7 +730,7 @@
         node2 = lys_find_child(ctx_node, mod, name, name_len, 0, getnext_opts);
         if (!node2) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Not found node \"%.*s\" in path.", name_len, name);
-            ret = LY_EINVAL;
+            ret = LY_EVALID;
             goto cleanup;
         }
         ctx_node = node2;
@@ -754,7 +754,7 @@
             && (p->node->nodetype & (LYS_LIST | LYS_LEAFLIST)) && !p->predicates) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
                lys_nodetype2str(p->node->nodetype), p->node->name);
-        return LY_EINVAL;
+        return LY_EVALID;
     }
 
 cleanup:
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 3ebcc0b..df43836 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -150,7 +150,7 @@
     }
 
 error:
-    *err = ly_err_new(LY_LLERR, LY_EINVAL, LYVE_DATA, errmsg, NULL, NULL);
+    *err = ly_err_new(LY_LLERR, LY_EVALID, LYVE_DATA, errmsg, NULL, NULL);
     return LY_EVALID;
 }
 
@@ -239,14 +239,14 @@
     }
 
 error:
-    *err = ly_err_new(LY_LLERR, LY_EINVAL, LYVE_DATA, errmsg, NULL, NULL);
+    *err = ly_err_new(LY_LLERR, LY_EVALID, LYVE_DATA, errmsg, NULL, NULL);
     return LY_EVALID;
 }
 
 API LY_ERR
 ly_type_parse_dec64(uint8_t fraction_digits, const char *value, size_t value_len, int64_t *ret, struct ly_err_item **err)
 {
-    LY_ERR rc = LY_EINVAL;
+    LY_ERR rc = LY_EVALID;
     char *errmsg = NULL;
     char *valcopy = NULL;
     size_t fraction = 0, size, len = 0, trailing_zeros;
@@ -339,7 +339,7 @@
 
 error:
     if (errmsg) {
-        *err = ly_err_new(LY_LLERR, LY_EINVAL, LYVE_DATA, errmsg, NULL, NULL);
+        *err = ly_err_new(LY_LLERR, rc, LYVE_DATA, errmsg, NULL, NULL);
     }
     return rc;
 }
@@ -522,8 +522,7 @@
                                        INT64_C(-9223372036854775807) - INT64_C(1), INT64_C(9223372036854775807), value, value_len, &i, err));
         break;
     default:
-        LOGINT(NULL);
-        return LY_EINVAL;
+        LOGINT_RET(NULL);
     }
 
     asprintf(&str, "%"PRId64, i);
@@ -596,8 +595,7 @@
         LY_CHECK_RET(ly_type_parse_uint("uint64", (options & LY_TYPE_OPTS_SCHEMA) ? 0 : 10, UINT64_C(18446744073709551615), value, value_len, &u, err));
         break;
     default:
-        LOGINT(NULL);
-        return LY_EINVAL;
+        LOGINT_RET(NULL);
     }
 
     asprintf(&str, "%"PRIu64, u);
@@ -657,7 +655,7 @@
     }
 
     if (!value || !value[0] || !value_len) {
-        *err = ly_err_new(LY_LLERR, LY_EINVAL, LYVE_DATA, strdup("Invalid empty decimal64 value."), NULL, NULL);
+        *err = ly_err_new(LY_LLERR, LY_EVALID, LYVE_DATA, strdup("Invalid empty decimal64 value."), NULL, NULL);
         return LY_EVALID;
     }