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/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 0861ffe..ce16eeb 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -492,9 +492,15 @@
goto cleanup;
}
if (!searchpaths) {
- searchpaths = ly_set_new();
+ if (ly_set_new(&searchpaths)) {
+ fprintf(stderr, "yanglint error: Preparing storage for searchpaths failed.\n");
+ goto cleanup;
+ }
}
- ly_set_add(searchpaths, optarg, 0);
+ if (ly_set_add(searchpaths, optarg, 0, NULL)) {
+ fprintf(stderr, "yanglint error: Storing searchpath failed.\n");
+ goto cleanup;
+ }
break;
#if 0
case 'r':
@@ -681,7 +687,10 @@
/* derefered setting of verbosity in libyang after context initiation */
ly_verb(verbose);
- mods = ly_set_new();
+ if (ly_set_new(&mods)) {
+ fprintf(stderr, "yanglint error: Preparing storage for the parsed modules failed.\n");
+ goto cleanup;
+ }
/* divide input files */
@@ -710,7 +719,10 @@
if (!mod) {
goto cleanup;
}
- ly_set_add(mods, (void *)mod, 0);
+ if (ly_set_add(mods, (void *)mod, 0, NULL)) {
+ fprintf(stderr, "yanglint error: Storing parsed module for further processing failed.\n");
+ goto cleanup;
+ }
} else {
if (autodetection && informat_d != LYD_XML) {
/* data file content autodetection is possible only for XML input */