-
Notifications
You must be signed in to change notification settings - Fork 309
union: remove assert in sort #2361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the assert is relevant and I would guess the issue is caused by leafrefs, not sure why it did not come up sooner. Try using the following code for the loop and see whether that fixes the assert.
struct lysc_type *type; /* put next to the other declarations */
/* compare according to the order of types */
types = ((struct lysc_type_union *)val1->realtype)->types;
LY_ARRAY_FOR(types, u) {
if (types[u]->basetype == LY_TYPE_LEAFREF) {
type = ((struct lysc_type_leafref *)types[u])->realtype;
} else {
type = types[u];
}
if (type == val1->subvalue->value.realtype) {
rc = 1;
break;
} else if (type == val2->subvalue->value.realtype) {
rc = -1;
break;
}
}
An assert was being hit in lyplg_type_sort_union() when evaluating leafrefs due to not using the realtype node. Signed-off-by: Michal Vasko <[email protected]> Signed-off-by: Brad House <[email protected]>
7e3a716
to
18dd3a6
Compare
You're right, I should have spent more time evaluating this. Your patch works properly. All test cases in both libyang and sonic-mgmt-common pass with your change. I've updated this PR to use your change. |
Getting assertion in lyplg_type_sort_union(). This assertion appears invalid as it comes up in test cases in SONiC but when removed everything passes.