Skip to content

Commit 4d83228

Browse files
committed
plugins types UPDATE compare callback assumes realtypes are the same
There is no reason the callbacks should need to handle this situation.
1 parent be2c2e9 commit 4d83228

19 files changed

+7
-112
lines changed

src/plugins_types.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,6 @@ lyplg_type_get_prefix(const struct lys_module *mod, LY_VALUE_FORMAT format, void
307307
LIBYANG_API_DEF LY_ERR
308308
lyplg_type_compare_simple(const struct lyd_value *val1, const struct lyd_value *val2)
309309
{
310-
if (val1->realtype != val2->realtype) {
311-
return LY_ENOT;
312-
}
313-
314310
if (val1->_canonical == val2->_canonical) {
315311
return LY_SUCCESS;
316312
}
@@ -1058,6 +1054,9 @@ lyplg_type_resolve_leafref(const struct lysc_type_leafref *lref, const struct ly
10581054
if (set.val.nodes[i].type != LYXP_NODE_ELEM) {
10591055
continue;
10601056
}
1057+
if (((struct lyd_node_term *)set.val.nodes[i].node)->value.realtype != value->realtype) {
1058+
continue;
1059+
}
10611060

10621061
if (!lref->plugin->compare(&((struct lyd_node_term *)set.val.nodes[i].node)->value, value)) {
10631062
break;

src/plugins_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ LIBYANG_API_DECL typedef LY_ERR (*lyplg_type_store_clb)(const struct ly_ctx *ctx
523523
* @param[in] tree External data tree (e.g. when validating RPC/Notification) with possibly referenced data.
524524
* @param[in,out] storage Storage of the value successfully filled by ::lyplg_type_store_clb. May be modified.
525525
* @param[out] err Optionally provided error information in case of failure. If not provided to the caller, a generic
526-
* error message is prepared instead. The error structure can be created by ::ly_err_new().
526+
* error message is prepared instead. The error structure can be created by ::ly_err_new().
527527
* @return LY_SUCCESS on success,
528528
* @return LY_ERR value on error.
529529
*/
@@ -533,12 +533,12 @@ LIBYANG_API_DECL typedef LY_ERR (*lyplg_type_validate_clb)(const struct ly_ctx *
533533
/**
534534
* @brief Callback for comparing 2 values of the same type.
535535
*
536-
* In case the value types (::lyd_value.realtype) are different, ::LY_ENOT must always be returned.
537-
* It can be assumed that the same context (dictionary) was used for storing both values.
536+
* It can be assumed that the same context (dictionary) was used for storing both values and the realtype
537+
* member of both the values is the same.
538538
*
539539
* @param[in] val1 First value to compare.
540540
* @param[in] val2 Second value to compare.
541-
* @return LY_SUCCESS if values are same (according to the type's definition of being same).
541+
* @return LY_SUCCESS if values are considered equal.
542542
* @return LY_ENOT if values differ.
543543
*/
544544
typedef LY_ERR (*lyplg_type_compare_clb)(const struct lyd_value *val1, const struct lyd_value *val2);

src/plugins_types/binary.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,6 @@ lyplg_type_compare_binary(const struct lyd_value *val1, const struct lyd_value *
340340
{
341341
struct lyd_value_binary *v1, *v2;
342342

343-
if (val1->realtype != val2->realtype) {
344-
return LY_ENOT;
345-
}
346-
347343
LYD_VALUE_GET(val1, v1);
348344
LYD_VALUE_GET(val2, v2);
349345

src/plugins_types/bits.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,6 @@ lyplg_type_compare_bits(const struct lyd_value *val1, const struct lyd_value *va
373373
struct lyd_value_bits *v1, *v2;
374374
struct lysc_type_bits *type_bits = (struct lysc_type_bits *)val1->realtype;
375375

376-
if (val1->realtype != val2->realtype) {
377-
return LY_ENOT;
378-
}
379-
380376
LYD_VALUE_GET(val1, v1);
381377
LYD_VALUE_GET(val2, v2);
382378

src/plugins_types/boolean.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ lyplg_type_store_boolean(const struct ly_ctx *ctx, const struct lysc_type *type,
106106
LIBYANG_API_DEF LY_ERR
107107
lyplg_type_compare_boolean(const struct lyd_value *val1, const struct lyd_value *val2)
108108
{
109-
if (val1->realtype != val2->realtype) {
110-
return LY_ENOT;
111-
}
112-
113109
if (val1->boolean != val2->boolean) {
114110
return LY_ENOT;
115111
}

src/plugins_types/date_and_time.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ lyplg_type_compare_date_and_time(const struct lyd_value *val1, const struct lyd_
153153
{
154154
struct lyd_value_date_and_time *v1, *v2;
155155

156-
if (val1->realtype != val2->realtype) {
157-
return LY_ENOT;
158-
}
159-
160156
LYD_VALUE_GET(val1, v1);
161157
LYD_VALUE_GET(val2, v2);
162158

src/plugins_types/decimal64.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ lyplg_type_store_decimal64(const struct ly_ctx *ctx, const struct lysc_type *typ
161161
LIBYANG_API_DEF LY_ERR
162162
lyplg_type_compare_decimal64(const struct lyd_value *val1, const struct lyd_value *val2)
163163
{
164-
if (val1->realtype != val2->realtype) {
165-
return LY_ENOT;
166-
}
167-
168164
/* if type is the same, the fraction digits are, too */
169165
if (val1->dec64 != val2->dec64) {
170166
return LY_ENOT;

src/plugins_types/identityref.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,6 @@ lyplg_type_store_identityref(const struct ly_ctx *ctx, const struct lysc_type *t
303303
LIBYANG_API_DEF LY_ERR
304304
lyplg_type_compare_identityref(const struct lyd_value *val1, const struct lyd_value *val2)
305305
{
306-
if (val1->realtype != val2->realtype) {
307-
return LY_ENOT;
308-
}
309-
310306
if (val1->ident == val2->ident) {
311307
return LY_SUCCESS;
312308
}

src/plugins_types/instanceid.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ lyplg_type_compare_instanceid(const struct lyd_value *val1, const struct lyd_val
257257
{
258258
LY_ARRAY_COUNT_TYPE u, v;
259259

260-
if (val1->realtype != val2->realtype) {
261-
return LY_ENOT;
262-
}
263-
264260
if (val1 == val2) {
265261
return LY_SUCCESS;
266262
} else if (LY_ARRAY_COUNT(val1->target) != LY_ARRAY_COUNT(val2->target)) {

src/plugins_types/integer.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,6 @@ lyplg_type_store_uint(const struct ly_ctx *ctx, const struct lysc_type *type, co
373373
LIBYANG_API_DEF LY_ERR
374374
lyplg_type_compare_uint(const struct lyd_value *val1, const struct lyd_value *val2)
375375
{
376-
if (val1->realtype != val2->realtype) {
377-
return LY_ENOT;
378-
}
379-
380376
switch (val1->realtype->basetype) {
381377
case LY_TYPE_UINT8:
382378
if (val1->uint8 != val2->uint8) {

0 commit comments

Comments
 (0)