Skip to content

Commit c621d86

Browse files
committed
schema compile BUGFIX parent of duplicate ext instance
1 parent d7e8c53 commit c621d86

File tree

4 files changed

+74
-46
lines changed

4 files changed

+74
-46
lines changed

src/schema_compile.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct lysc_unres_dflt {
166166
LY_ARRAY_CREATE_RET(CTX, NEW_ARRAY, LY_ARRAY_COUNT(ORIG_ARRAY), LY_EMEM); \
167167
LY_ARRAY_FOR(ORIG_ARRAY, __u) { \
168168
LY_ARRAY_INCREMENT(NEW_ARRAY); \
169-
LY_CHECK_RET(DUP_FUNC(CTX, &(NEW_ARRAY)[__u], &(ORIG_ARRAY)[__u])); \
169+
LY_CHECK_RET(DUP_FUNC(CTX, &(ORIG_ARRAY)[__u], &(NEW_ARRAY)[__u])); \
170170
} \
171171
}
172172

@@ -176,7 +176,17 @@ struct lysc_unres_dflt {
176176
LY_ARRAY_CREATE_RET(CTX, NEW_ARRAY, LY_ARRAY_COUNT(ORIG_ARRAY), LY_EMEM); \
177177
LY_ARRAY_FOR(ORIG_ARRAY, __u) { \
178178
LY_ARRAY_INCREMENT(NEW_ARRAY); \
179-
LY_CHECK_RET(DUP_FUNC(CTX, PMOD, &(NEW_ARRAY)[__u], &(ORIG_ARRAY)[__u])); \
179+
LY_CHECK_RET(DUP_FUNC(CTX, PMOD, &(ORIG_ARRAY)[__u], &(NEW_ARRAY)[__u])); \
180+
} \
181+
}
182+
183+
#define DUP_EXTS(CTX, PMOD, PARENT, PARENT_STMT, ORIG_ARRAY, NEW_ARRAY, DUP_FUNC) \
184+
if (ORIG_ARRAY) { \
185+
LY_ARRAY_COUNT_TYPE __u; \
186+
LY_ARRAY_CREATE_RET(CTX, NEW_ARRAY, LY_ARRAY_COUNT(ORIG_ARRAY), LY_EMEM); \
187+
LY_ARRAY_FOR(ORIG_ARRAY, __u) { \
188+
LY_ARRAY_INCREMENT(NEW_ARRAY); \
189+
LY_CHECK_RET(DUP_FUNC(CTX, PMOD, PARENT, PARENT_STMT, &(ORIG_ARRAY)[__u], &(NEW_ARRAY)[__u])); \
180190
} \
181191
}
182192

src/schema_compile_amend.c

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,16 @@ lys_precompile_uses_augments_refines(struct lysc_ctx *ctx, struct lysp_node_uses
308308
return ret;
309309
}
310310

311+
/**
312+
* @brief Duplicate parsed extension children, recursively.
313+
*
314+
* @param[in] ctx Context.
315+
* @param[in] orig_child First original child to duplicate.
316+
* @param[in,out] child Duplicated children to add to.
317+
* @return LY_ERR value.
318+
*/
311319
static LY_ERR
312-
lysp_ext_children_dup(const struct ly_ctx *ctx, struct lysp_stmt **child, const struct lysp_stmt *orig_child)
320+
lysp_ext_children_dup(const struct ly_ctx *ctx, const struct lysp_stmt *orig_child, struct lysp_stmt **child)
313321
{
314322
struct lysp_stmt *ch = NULL;
315323

@@ -335,15 +343,25 @@ lysp_ext_children_dup(const struct ly_ctx *ctx, struct lysp_stmt **child, const
335343
ch->kw = orig_child->kw;
336344

337345
/* recursive children */
338-
LY_CHECK_RET(lysp_ext_children_dup(ctx, &ch->child, orig_child->child));
346+
LY_CHECK_RET(lysp_ext_children_dup(ctx, orig_child->child, &ch->child));
339347
}
340348

341349
return LY_SUCCESS;
342350
}
343351

352+
/**
353+
* @brief Duplicate parsed extension instance.
354+
*
355+
* @param[in] ctx Context.
356+
* @param[in] pmod Current parsed module.
357+
* @param[in] parent Parent of the duplicated ext instance.
358+
* @param[in] parent_stmt Parent statement of the duplicated ext instance (should be @p parent).
359+
* @param[out] ext Duplicated ext instance to fill.
360+
* @return LY_ERR value.
361+
*/
344362
static LY_ERR
345-
lysp_ext_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct lysp_ext_instance *ext,
346-
const struct lysp_ext_instance *orig_ext)
363+
lysp_ext_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, void *parent, enum ly_stmt parent_stmt,
364+
const struct lysp_ext_instance *orig_ext, struct lysp_ext_instance *ext)
347365
{
348366
LY_ERR ret = LY_SUCCESS;
349367
struct ly_set pmods = {0};
@@ -355,13 +373,13 @@ lysp_ext_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct ly
355373
LY_CHECK_GOTO(ret = ly_dup_prefix_data(ctx, orig_ext->format, orig_ext->prefix_data, &ext->prefix_data), cleanup);
356374
ext->def = orig_ext->def;
357375

358-
ext->parent = orig_ext->parent;
359-
ext->parent_stmt = orig_ext->parent_stmt;
376+
ext->parent = parent;
377+
ext->parent_stmt = parent_stmt;
360378
ext->parent_stmt_index = orig_ext->parent_stmt_index;
361379
ext->flags = orig_ext->flags;
362380
ext->record = orig_ext->record;
363381

364-
LY_CHECK_GOTO(ret = lysp_ext_children_dup(ctx, &ext->child, orig_ext->child), cleanup);
382+
LY_CHECK_GOTO(ret = lysp_ext_children_dup(ctx, orig_ext->child, &ext->child), cleanup);
365383
if (ext->record && ext->record->plugin.parse) {
366384
/* parse again */
367385
LY_CHECK_GOTO(ret = ly_set_add(&pmods, pmod, 1, NULL), cleanup);
@@ -374,8 +392,8 @@ lysp_ext_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct ly
374392
}
375393

376394
static LY_ERR
377-
lysp_restr_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct lysp_restr *restr,
378-
const struct lysp_restr *orig_restr)
395+
lysp_restr_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, const struct lysp_restr *orig_restr,
396+
struct lysp_restr *restr)
379397
{
380398
LY_ERR ret = LY_SUCCESS;
381399

@@ -386,14 +404,14 @@ lysp_restr_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct
386404
DUP_STRING(ctx, orig_restr->eapptag, restr->eapptag, ret);
387405
DUP_STRING(ctx, orig_restr->dsc, restr->dsc, ret);
388406
DUP_STRING(ctx, orig_restr->ref, restr->ref, ret);
389-
DUP_ARRAY2(ctx, pmod, orig_restr->exts, restr->exts, lysp_ext_dup);
407+
DUP_EXTS(ctx, pmod, restr, LY_STMT_MUST, orig_restr->exts, restr->exts, lysp_ext_dup);
390408
}
391409

392410
return ret;
393411
}
394412

395413
static LY_ERR
396-
lysp_string_dup(const struct ly_ctx *ctx, const char **str, const char **orig_str)
414+
lysp_string_dup(const struct ly_ctx *ctx, const char **orig_str, const char **str)
397415
{
398416
LY_ERR ret = LY_SUCCESS;
399417

@@ -403,7 +421,7 @@ lysp_string_dup(const struct ly_ctx *ctx, const char **str, const char **orig_st
403421
}
404422

405423
LY_ERR
406-
lysp_qname_dup(const struct ly_ctx *ctx, struct lysp_qname *qname, const struct lysp_qname *orig_qname)
424+
lysp_qname_dup(const struct ly_ctx *ctx, const struct lysp_qname *orig_qname, struct lysp_qname *qname)
407425
{
408426
LY_ERR ret = LY_SUCCESS;
409427

@@ -419,8 +437,8 @@ lysp_qname_dup(const struct ly_ctx *ctx, struct lysp_qname *qname, const struct
419437
}
420438

421439
static LY_ERR
422-
lysp_type_enum_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct lysp_type_enum *enm,
423-
const struct lysp_type_enum *orig_enm)
440+
lysp_type_enum_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, const struct lysp_type_enum *orig_enm,
441+
struct lysp_type_enum *enm)
424442
{
425443
LY_ERR ret = LY_SUCCESS;
426444

@@ -429,15 +447,15 @@ lysp_type_enum_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, str
429447
DUP_STRING(ctx, orig_enm->ref, enm->ref, ret);
430448
enm->value = orig_enm->value;
431449
DUP_ARRAY(ctx, orig_enm->iffeatures, enm->iffeatures, lysp_qname_dup);
432-
DUP_ARRAY2(ctx, pmod, orig_enm->exts, enm->exts, lysp_ext_dup);
450+
DUP_EXTS(ctx, pmod, enm, LY_STMT_ENUM, orig_enm->exts, enm->exts, lysp_ext_dup);
433451
enm->flags = orig_enm->flags;
434452

435453
return ret;
436454
}
437455

438456
static LY_ERR
439-
lysp_type_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct lysp_type *type,
440-
const struct lysp_type *orig_type)
457+
lysp_type_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, const struct lysp_type *orig_type,
458+
struct lysp_type *type)
441459
{
442460
LY_ERR ret = LY_SUCCESS;
443461

@@ -449,13 +467,13 @@ lysp_type_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct l
449467
if (orig_type->range) {
450468
type->range = calloc(1, sizeof *type->range);
451469
LY_CHECK_ERR_RET(!type->range, LOGMEM(ctx), LY_EMEM);
452-
LY_CHECK_RET(lysp_restr_dup(ctx, pmod, type->range, orig_type->range));
470+
LY_CHECK_RET(lysp_restr_dup(ctx, pmod, orig_type->range, type->range));
453471
}
454472

455473
if (orig_type->length) {
456474
type->length = calloc(1, sizeof *type->length);
457475
LY_CHECK_ERR_RET(!type->length, LOGMEM(ctx), LY_EMEM);
458-
LY_CHECK_RET(lysp_restr_dup(ctx, pmod, type->length, orig_type->length));
476+
LY_CHECK_RET(lysp_restr_dup(ctx, pmod, orig_type->length, type->length));
459477
}
460478

461479
DUP_ARRAY2(ctx, pmod, orig_type->patterns, type->patterns, lysp_restr_dup);
@@ -464,7 +482,7 @@ lysp_type_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct l
464482
LY_CHECK_GOTO(ret = lyxp_expr_dup(ctx, orig_type->path, 0, 0, &type->path), done);
465483
DUP_ARRAY(ctx, orig_type->bases, type->bases, lysp_string_dup);
466484
DUP_ARRAY2(ctx, pmod, orig_type->types, type->types, lysp_type_dup);
467-
DUP_ARRAY2(ctx, pmod, orig_type->exts, type->exts, lysp_ext_dup);
485+
DUP_EXTS(ctx, pmod, type, LY_STMT_TYPE, orig_type->exts, type->exts, lysp_ext_dup);
468486

469487
type->pmod = orig_type->pmod;
470488
type->compiled = orig_type->compiled;
@@ -486,7 +504,7 @@ lysp_when_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct l
486504
DUP_STRING(ctx, orig_when->cond, when->cond, ret);
487505
DUP_STRING(ctx, orig_when->dsc, when->dsc, ret);
488506
DUP_STRING(ctx, orig_when->ref, when->ref, ret);
489-
DUP_ARRAY2(ctx, pmod, orig_when->exts, when->exts, lysp_ext_dup);
507+
DUP_EXTS(ctx, pmod, when, LY_STMT_WHEN, orig_when->exts, when->exts, lysp_ext_dup);
490508

491509
return ret;
492510
}
@@ -505,7 +523,7 @@ lysp_node_common_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, s
505523
DUP_STRING(ctx, orig->dsc, node->dsc, ret);
506524
DUP_STRING(ctx, orig->ref, node->ref, ret);
507525
DUP_ARRAY(ctx, orig->iffeatures, node->iffeatures, lysp_qname_dup);
508-
DUP_ARRAY2(ctx, pmod, orig->exts, node->exts, lysp_ext_dup);
526+
DUP_EXTS(ctx, pmod, node, lyplg_ext_nodetype2stmt(node->nodetype), orig->exts, node->exts, lysp_ext_dup);
509527

510528
return ret;
511529
}
@@ -566,17 +584,17 @@ lysp_node_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct l
566584

567585
DUP_PWHEN(ctx, pmod, orig_leaf->when, leaf->when);
568586
DUP_ARRAY2(ctx, pmod, orig_leaf->musts, leaf->musts, lysp_restr_dup);
569-
LY_CHECK_RET(lysp_type_dup(ctx, pmod, &leaf->type, &orig_leaf->type));
587+
LY_CHECK_RET(lysp_type_dup(ctx, pmod, &orig_leaf->type, &leaf->type));
570588
DUP_STRING(ctx, orig_leaf->units, leaf->units, ret);
571-
LY_CHECK_RET(lysp_qname_dup(ctx, &leaf->dflt, &orig_leaf->dflt));
589+
LY_CHECK_RET(lysp_qname_dup(ctx, &orig_leaf->dflt, &leaf->dflt));
572590
break;
573591
case LYS_LEAFLIST:
574592
llist = (struct lysp_node_leaflist *)node;
575593
orig_llist = (const struct lysp_node_leaflist *)orig;
576594

577595
DUP_PWHEN(ctx, pmod, orig_llist->when, llist->when);
578596
DUP_ARRAY2(ctx, pmod, orig_llist->musts, llist->musts, lysp_restr_dup);
579-
LY_CHECK_RET(lysp_type_dup(ctx, pmod, &llist->type, &orig_llist->type));
597+
LY_CHECK_RET(lysp_type_dup(ctx, pmod, &orig_llist->type, &llist->type));
580598
DUP_STRING(ctx, orig_llist->units, llist->units, ret);
581599
DUP_ARRAY(ctx, orig_llist->dflts, llist->dflts, lysp_qname_dup);
582600
llist->min = orig_llist->min;
@@ -600,7 +618,7 @@ lysp_node_dup(const struct ly_ctx *ctx, const struct lysp_module *pmod, struct l
600618

601619
DUP_PWHEN(ctx, pmod, orig_choice->when, choice->when);
602620
/* we do not need children */
603-
LY_CHECK_RET(lysp_qname_dup(ctx, &choice->dflt, &orig_choice->dflt));
621+
LY_CHECK_RET(lysp_qname_dup(ctx, &orig_choice->dflt, &choice->dflt));
604622
break;
605623
case LYS_CASE:
606624
cas = (struct lysp_node_case *)node;
@@ -792,7 +810,7 @@ lys_apply_refine(struct lysc_ctx *ctx, struct lysp_refine *rfn, const struct lys
792810
AMEND_CHECK_CARDINALITY(rfn->dflts, 1, "refine", "default");
793811

794812
lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
795-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_leaf *)target)->dflt, &rfn->dflts[0]), cleanup);
813+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &rfn->dflts[0], &((struct lysp_node_leaf *)target)->dflt), cleanup);
796814
break;
797815
case LYS_LEAFLIST:
798816
if (rfn->dflts[0].mod->version < LYS_VERSION_1_1) {
@@ -806,14 +824,14 @@ lys_apply_refine(struct lysc_ctx *ctx, struct lysp_refine *rfn, const struct lys
806824
((struct lysp_node_leaflist *)target)->dflts = NULL;
807825
LY_ARRAY_FOR(rfn->dflts, u) {
808826
LY_ARRAY_NEW_GOTO(ctx->ctx, ((struct lysp_node_leaflist *)target)->dflts, qname, ret, cleanup);
809-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, qname, &rfn->dflts[u]), cleanup);
827+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &rfn->dflts[u], qname), cleanup);
810828
}
811829
break;
812830
case LYS_CHOICE:
813831
AMEND_CHECK_CARDINALITY(rfn->dflts, 1, "refine", "default");
814832

815833
lydict_remove(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
816-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_choice *)target)->dflt, &rfn->dflts[0]), cleanup);
834+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &rfn->dflts[0], &((struct lysp_node_choice *)target)->dflt), cleanup);
817835
break;
818836
default:
819837
AMEND_WRONG_NODETYPE("refine", "replace", "default");
@@ -890,7 +908,7 @@ lys_apply_refine(struct lysc_ctx *ctx, struct lysp_refine *rfn, const struct lys
890908

891909
LY_ARRAY_FOR(rfn->musts, u) {
892910
LY_ARRAY_NEW_GOTO(ctx->ctx, *musts, must, ret, cleanup);
893-
LY_CHECK_GOTO(ret = lysp_restr_dup(ctx->ctx, rfn_pmod, must, &rfn->musts[u]), cleanup);
911+
LY_CHECK_GOTO(ret = lysp_restr_dup(ctx->ctx, rfn_pmod, &rfn->musts[u], must), cleanup);
894912
}
895913
}
896914

@@ -944,12 +962,12 @@ lys_apply_refine(struct lysc_ctx *ctx, struct lysp_refine *rfn, const struct lys
944962

945963
LY_ARRAY_FOR(rfn->iffeatures, u) {
946964
LY_ARRAY_NEW_GOTO(ctx->ctx, target->iffeatures, qname, ret, cleanup);
947-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, qname, &rfn->iffeatures[u]), cleanup);
965+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &rfn->iffeatures[u], qname), cleanup);
948966
}
949967
}
950968

951969
/* extension instances */
952-
DUP_ARRAY2(ctx->ctx, rfn_pmod, rfn->exts, target->exts, lysp_ext_dup);
970+
DUP_EXTS(ctx->ctx, rfn_pmod, target, lyplg_ext_nodetype2stmt(target->nodetype), rfn->exts, target->exts, lysp_ext_dup);
953971

954972
cleanup:
955973
ctx->cur_mod = orig_mod;
@@ -1008,7 +1026,7 @@ lys_apply_deviate_add(struct lysc_ctx *ctx, struct lysp_deviate_add *d, struct l
10081026

10091027
LY_ARRAY_FOR(d->musts, u) {
10101028
LY_ARRAY_NEW_GOTO(ctx->ctx, *musts, must, ret, cleanup);
1011-
LY_CHECK_GOTO(ret = lysp_restr_dup(ctx->ctx, ctx->pmod, must, &d->musts[u]), cleanup);
1029+
LY_CHECK_GOTO(ret = lysp_restr_dup(ctx->ctx, ctx->pmod, &d->musts[u], must), cleanup);
10121030
}
10131031
}
10141032

@@ -1023,7 +1041,7 @@ lys_apply_deviate_add(struct lysc_ctx *ctx, struct lysp_deviate_add *d, struct l
10231041

10241042
LY_ARRAY_FOR(d->uniques, u) {
10251043
LY_ARRAY_NEW_GOTO(ctx->ctx, ((struct lysp_node_list *)target)->uniques, qname, ret, cleanup);
1026-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, qname, &d->uniques[u]), cleanup);
1044+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->uniques[u], qname), cleanup);
10271045
}
10281046
}
10291047

@@ -1034,19 +1052,19 @@ lys_apply_deviate_add(struct lysc_ctx *ctx, struct lysp_deviate_add *d, struct l
10341052
AMEND_CHECK_CARDINALITY(d->dflts, 1, "deviation", "default");
10351053
DEV_CHECK_NONPRESENCE(struct lysp_node_leaf *, dflt.str, "default", dflt.str);
10361054

1037-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_leaf *)target)->dflt, &d->dflts[0]), cleanup);
1055+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflts[0], &((struct lysp_node_leaf *)target)->dflt), cleanup);
10381056
break;
10391057
case LYS_LEAFLIST:
10401058
LY_ARRAY_FOR(d->dflts, u) {
10411059
LY_ARRAY_NEW_GOTO(ctx->ctx, ((struct lysp_node_leaflist *)target)->dflts, qname, ret, cleanup);
1042-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, qname, &d->dflts[u]), cleanup);
1060+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflts[u], qname), cleanup);
10431061
}
10441062
break;
10451063
case LYS_CHOICE:
10461064
AMEND_CHECK_CARDINALITY(d->dflts, 1, "deviation", "default");
10471065
DEV_CHECK_NONPRESENCE(struct lysp_node_choice *, dflt.str, "default", dflt.str);
10481066

1049-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_choice *)target)->dflt, &d->dflts[0]), cleanup);
1067+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflts[0], &((struct lysp_node_choice *)target)->dflt), cleanup);
10501068
break;
10511069
default:
10521070
AMEND_WRONG_NODETYPE("deviation", "add", "default");
@@ -1314,7 +1332,7 @@ lys_apply_deviate_replace(struct lysc_ctx *ctx, struct lysp_deviate_rpl *d, stru
13141332
}
13151333

13161334
lysp_type_free(&ctx->free_ctx, &((struct lysp_node_leaf *)target)->type);
1317-
lysp_type_dup(ctx->ctx, ctx->pmod, &((struct lysp_node_leaf *)target)->type, d->type);
1335+
lysp_type_dup(ctx->ctx, ctx->pmod, d->type, &((struct lysp_node_leaf *)target)->type);
13181336
}
13191337

13201338
/* [units-stmt] */
@@ -1339,13 +1357,13 @@ lys_apply_deviate_replace(struct lysc_ctx *ctx, struct lysp_deviate_rpl *d, stru
13391357
DEV_CHECK_PRESENCE(struct lysp_node_leaf *, dflt.str, "replacing", "default", d->dflt.str);
13401358

13411359
lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
1342-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_leaf *)target)->dflt, &d->dflt), cleanup);
1360+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflt, &((struct lysp_node_leaf *)target)->dflt), cleanup);
13431361
break;
13441362
case LYS_CHOICE:
13451363
DEV_CHECK_PRESENCE(struct lysp_node_choice *, dflt.str, "replacing", "default", d->dflt);
13461364

13471365
lydict_remove(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
1348-
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_choice *)target)->dflt, &d->dflt), cleanup);
1366+
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflt, &((struct lysp_node_choice *)target)->dflt), cleanup);
13491367
break;
13501368
default:
13511369
AMEND_WRONG_NODETYPE("deviation", "replace", "default");
@@ -1497,7 +1515,7 @@ lys_apply_deviation(struct lysc_ctx *ctx, struct lysp_deviation *dev, const stru
14971515
}
14981516

14991517
/* deviation extension instances */
1500-
DUP_ARRAY2(ctx->ctx, dev_pmod, dev->exts, target->exts, lysp_ext_dup);
1518+
DUP_EXTS(ctx->ctx, dev_pmod, target, lyplg_ext_nodetype2stmt(target->nodetype), dev->exts, target->exts, lysp_ext_dup);
15011519

15021520
cleanup:
15031521
ctx->cur_mod = orig_mod;

src/schema_compile_amend.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ LY_ERR lys_precompile_uses_augments_refines(struct lysc_ctx *ctx, struct lysp_no
8181
* @brief Duplicate qname structure.
8282
*
8383
* @param[in] ctx libyang context.
84-
* @param[in,out] qname Structure to fill.
8584
* @param[in] orig_qname Structure to read from.
85+
* @param[in,out] qname Structure to fill.
8686
* @return LY_ERR value.
8787
*/
88-
LY_ERR lysp_qname_dup(const struct ly_ctx *ctx, struct lysp_qname *qname, const struct lysp_qname *orig_qname);
88+
LY_ERR lysp_qname_dup(const struct ly_ctx *ctx, const struct lysp_qname *orig_qname, struct lysp_qname *qname);
8989

9090
/**
9191
* @brief Free a compiled augment temporary structure.

src/schema_compile_node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ lysc_unres_leaf_dflt_add(struct lysc_ctx *ctx, struct lysc_node_leaf *leaf, stru
194194

195195
r->dflt = malloc(sizeof *r->dflt);
196196
LY_CHECK_GOTO(!r->dflt, error);
197-
LY_CHECK_GOTO(lysp_qname_dup(ctx->ctx, r->dflt, dflt), error);
197+
LY_CHECK_GOTO(lysp_qname_dup(ctx->ctx, dflt, r->dflt), error);
198198

199199
return LY_SUCCESS;
200200

0 commit comments

Comments
 (0)