set CHANGE make ly_set* functions return LY_ERR values

unify ly_set* function that were returning -1 as error indicator
combined with positive value indicating index inside the set. The most
of other libyang functions return LY_ERR to indicate result. The problem
of these functions was also the limited range of the returned index.
While internally index is uint32_t, it was limited only to a positive
part of int type.
diff --git a/src/tree_data.c b/src/tree_data.c
index a4c4903..02b9196 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1434,7 +1434,7 @@
                 if (ret == LY_EINCOMPLETE) {
                     if (node_types) {
                         /* remember to resolve type */
-                        ly_set_add(node_types, node, LY_SET_OPT_USEASLIST);
+                        LY_CHECK_RET(ly_set_add(node_types, node, LY_SET_OPT_USEASLIST, NULL));
                     }
                 } else if (ret) {
                     return ret;
@@ -1444,7 +1444,7 @@
 
                 if (iter->when && node_when) {
                     /* remember to resolve when */
-                    ly_set_add(node_when, node, LY_SET_OPT_USEASLIST);
+                    LY_CHECK_RET(ly_set_add(node_when, node, LY_SET_OPT_USEASLIST, NULL));
                 }
                 if (diff) {
                     /* add into diff */
@@ -1462,7 +1462,7 @@
                     if (ret == LY_EINCOMPLETE) {
                         if (node_types) {
                             /* remember to resolve type */
-                            ly_set_add(node_types, node, LY_SET_OPT_USEASLIST);
+                            LY_CHECK_RET(ly_set_add(node_types, node, LY_SET_OPT_USEASLIST, NULL));
                         }
                     } else if (ret) {
                         return ret;
@@ -1472,7 +1472,7 @@
 
                     if (iter->when && node_when) {
                         /* remember to resolve when */
-                        ly_set_add(node_when, node, LY_SET_OPT_USEASLIST);
+                        LY_CHECK_RET(ly_set_add(node_when, node, LY_SET_OPT_USEASLIST, NULL));
                     }
                     if (diff) {
                         /* add into diff */
@@ -3335,8 +3335,8 @@
     LY_CHECK_GOTO(ret, cleanup);
 
     /* allocate return set */
-    *set = ly_set_new();
-    LY_CHECK_ERR_GOTO(!*set, LOGMEM(LYD_CTX(ctx_node)); ret = LY_EMEM, cleanup);
+    ret = ly_set_new(set);
+    LY_CHECK_GOTO(ret, cleanup);
 
     /* transform into ly_set */
     if (xp_set.type == LYXP_SET_NODE_SET) {
@@ -3347,7 +3347,8 @@
 
         for (i = 0; i < xp_set.used; ++i) {
             if (xp_set.val.nodes[i].type == LYXP_NODE_ELEM) {
-                ly_set_add(*set, xp_set.val.nodes[i].node, LY_SET_OPT_USEASLIST);
+                ret = ly_set_add(*set, xp_set.val.nodes[i].node, LY_SET_OPT_USEASLIST, NULL);
+                LY_CHECK_GOTO(ret, cleanup);
             }
         }
     }