Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions tools/lint/cmd_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ int
cmd_load_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv)
{
const char *all_features[] = {"*", NULL};
char *revision;
char *name, *revision;
const char **features = NULL;
int ret = 0;

assert(posv);

Expand All @@ -128,8 +129,14 @@ cmd_load_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv)
yo->ctx_options = 0;
}

name = strdup(posv);
if (!name) {
YLMSG_E("Memory allocation error.");
return 1;
}

/* get revision */
revision = (char *)strchr(posv, '@');
revision = strchr(name, '@');
if (revision) {
revision[0] = '\0';
++revision;
Expand All @@ -139,14 +146,15 @@ cmd_load_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv)
if (!yo->schema_features.count) {
features = all_features;
} else {
get_features(&yo->schema_features, posv, &features);
get_features(&yo->schema_features, name, &features);
}

/* load the module */
if (!ly_ctx_load_module(*ctx, posv, revision, features)) {
if (!ly_ctx_load_module(*ctx, name, revision, features)) {
/* libyang printed the error messages */
return 1;
ret = 1;
}

return 0;
free(name);
return ret;
}
Loading