Skip to content

Commit

Permalink
log UPDATE avoid using LY_EVALID without vecode
Browse files Browse the repository at this point in the history
Refs #2215
  • Loading branch information
michalvasko committed Apr 5, 2024
1 parent ac43d12 commit 56318fe
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 15 deletions.
6 changes: 0 additions & 6 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE
{
char *msg = NULL;
ly_bool free_strs = 1, lolog, lostore;
const struct ly_err_item *e;

/* learn effective logger options */
if (temp_ly_log_opts) {
Expand Down Expand Up @@ -636,11 +635,6 @@ log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE
/* store the error/warning in the context (if we need to store errors internally, it does not matter what are
* the user log options) */
if ((level < LY_LLVRB) && ctx && lostore) {
if (((err & ~LY_EPLUGIN) == LY_EVALID) && (vecode == LYVE_SUCCESS)) {
/* assume we are inheriting the error, so inherit vecode as well */
e = ly_err_last(ctx);
vecode = e->vecode;
}
free_strs = 0;
if (log_store(ctx, level, err, vecode, msg, data_path, schema_path, line, apptag ? strdup(apptag) : NULL)) {
goto cleanup;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins_types/ipv4_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ lyplg_type_print_ipv4_address(const struct ly_ctx *ctx, const struct lyd_value *
/* get the address in string */
if (!inet_ntop(AF_INET, &val->addr, ret, INET_ADDRSTRLEN)) {
free(ret);
LOGERR(ctx, LY_EVALID, "Failed to get IPv4 address in string (%s).", strerror(errno));
LOGERR(ctx, LY_ESYS, "Failed to get IPv4 address in string (%s).", strerror(errno));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins_types/ipv4_address_no_zone.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ lyplg_type_print_ipv4_address_no_zone(const struct ly_ctx *ctx, const struct lyd
/* get the address in string */
if (!inet_ntop(AF_INET, &val->addr, ret, INET_ADDRSTRLEN)) {
free(ret);
LOGERR(ctx, LY_EVALID, "Failed to get IPv4 address in string (%s).", strerror(errno));
LOGERR(ctx, LY_ESYS, "Failed to get IPv4 address in string (%s).", strerror(errno));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins_types/ipv6_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ lyplg_type_print_ipv6_address(const struct ly_ctx *ctx, const struct lyd_value *
/* get the address in string */
if (!inet_ntop(AF_INET6, &val->addr, ret, INET6_ADDRSTRLEN)) {
free(ret);
LOGERR(ctx, LY_EVALID, "Failed to get IPv6 address in string (%s).", strerror(errno));
LOGERR(ctx, LY_ESYS, "Failed to get IPv6 address in string (%s).", strerror(errno));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins_types/ipv6_address_no_zone.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ lyplg_type_print_ipv6_address_no_zone(const struct ly_ctx *ctx, const struct lyd
/* get the address in string */
if (!inet_ntop(AF_INET6, &val->addr, ret, INET6_ADDRSTRLEN)) {
free(ret);
LOGERR(ctx, LY_EVALID, "Failed to get IPv6 address in string (%s).", strerror(errno));
LOGERR(ctx, LY_ESYS, "Failed to get IPv6 address in string (%s).", strerror(errno));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tree_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ lys_parse_in(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format,
const struct ly_err_item *e = ly_err_last(ctx);

if (e && (!e->schema_path || e->line)) {
LOGERR(ctx, ret, "Parsing module \"%s\" failed.", mod->name);
LOGERR(ctx, LY_EOTHER, "Parsing module \"%s\" failed.", mod->name);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -4075,9 +4075,9 @@ xpath_deref(struct lyxp_set **args, uint32_t UNUSED(arg_count), struct lyxp_set
r = lyplg_type_resolve_leafref((struct lysc_type_leafref *)sleaf->type, &leaf->node, &leaf->value, set->tree,
&targets, &errmsg);
if (r) {
LOGERR(set->ctx, LY_EVALID, "%s", errmsg);
LOGERR(set->ctx, LY_EINVAL, "%s", errmsg);
free(errmsg);
ret = LY_EVALID;
ret = LY_EINVAL;
goto cleanup;
}

Expand All @@ -4088,9 +4088,9 @@ xpath_deref(struct lyxp_set **args, uint32_t UNUSED(arg_count), struct lyxp_set
} else {
assert(sleaf->type->basetype == LY_TYPE_INST);
if (ly_path_eval(leaf->value.target, set->tree, NULL, &node)) {
LOGERR(set->ctx, LY_EVALID, "Invalid instance-identifier \"%s\" value - required instance not found.",
LOGERR(set->ctx, LY_EINVAL, "Invalid instance-identifier \"%s\" value - required instance not found.",
lyd_get_value(&leaf->node));
ret = LY_EVALID;
ret = LY_EINVAL;
goto cleanup;
}

Expand Down

0 comments on commit 56318fe

Please sign in to comment.