1
0
Fork 0

Merging upstream version 3.4.2+dfsg.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 08:03:59 +01:00
parent 511f72b68b
commit 948b3e00b3
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
75 changed files with 1082 additions and 878 deletions

View file

@ -885,7 +885,7 @@ lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const cha
return _lyd_new_term(parent, module, name, value, value ? strlen(value) : 0, options, node);
}
LIBYANG_API_DECL LY_ERR
LIBYANG_API_DEF LY_ERR
lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
const void *value, size_t value_len, uint32_t options, struct lyd_node **node)
{
@ -1089,6 +1089,7 @@ lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name
const char *prefix, const char *module_name, struct lyd_node **node)
{
struct lyd_node *ret = NULL;
uint32_t hints = 0;
LY_CHECK_ARG_RET(ctx, parent || ctx, parent || node, name, module_name, !prefix || !strcmp(prefix, module_name), LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
@ -1098,10 +1099,12 @@ lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name
}
if (!value) {
value = "";
} else if (!strcmp(value, "[null]")) {
hints |= LYD_VALHINT_EMPTY;
}
LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), prefix, prefix ? strlen(prefix) : 0, module_name,
strlen(module_name), value, strlen(value), NULL, LY_VALUE_JSON, NULL, 0, &ret));
strlen(module_name), value, strlen(value), NULL, LY_VALUE_JSON, NULL, hints, &ret));
if (parent) {
lyd_insert_node(parent, NULL, ret, LYD_INSERT_NODE_LAST);
}
@ -1626,6 +1629,7 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
ly_bool store_only = (options & LYD_NEW_VAL_STORE_ONLY) ? 1 : 0;
LY_ARRAY_COUNT_TYPE path_idx = 0, orig_count = 0;
LY_VALUE_FORMAT format;
uint32_t hints;
assert(parent || ctx);
assert(path && ((path[0] == '/') || parent));
@ -1728,9 +1732,13 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
}
if (r && (r != LY_EINCOMPLETE)) {
/* creating opaque leaf-list */
hints = LYD_NODEHINT_LEAFLIST;
if (value && (format == LY_VALUE_JSON) && !ly_strncmp("[null]", value, value_len)) {
hints |= LYD_VALHINT_EMPTY;
}
LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0,
schema->module->name, strlen(schema->module->name), value, value_len, NULL, format, NULL,
LYD_NODEHINT_LEAFLIST, &node), cleanup);
hints, &node), cleanup);
break;
}
}
@ -1765,8 +1773,12 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
}
if (r && (r != LY_EINCOMPLETE)) {
/* creating opaque leaf */
hints = 0;
if (value && (format == LY_VALUE_JSON) && !ly_strncmp("[null]", value, value_len)) {
hints |= LYD_VALHINT_EMPTY;
}
LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0,
schema->module->name, strlen(schema->module->name), value, value_len, NULL, format, NULL, 0, &node),
schema->module->name, strlen(schema->module->name), value, value_len, NULL, format, NULL, hints, &node),
cleanup);
break;
}
@ -1811,7 +1823,7 @@ cleanup:
LY_ARRAY_INCREMENT(p);
}
}
ly_path_free(ctx, p);
ly_path_free(p);
if (!ret) {
/* set out params only on success */
if (new_parent) {