Skip to content

Commit 1b7d73d

Browse files
committed
Merge branch 'devel'
2 parents d90f52e + 2b677b8 commit 1b7d73d

39 files changed

+1570
-1969
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ set(CMAKE_MACOSX_RPATH TRUE)
2121
# micro version is changed with a set of small changes or bugfixes anywhere in the project.
2222
set(LIBYANG_MAJOR_VERSION 1)
2323
set(LIBYANG_MINOR_VERSION 0)
24-
set(LIBYANG_MICRO_VERSION 109)
24+
set(LIBYANG_MICRO_VERSION 130)
2525
set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION})
2626

2727
# Version of the library
2828
# Major version is changed with every backward non-compatible API/ABI change in libyang, minor version changes
2929
# with backward compatible change and micro version is connected with any internal change of the library.
3030
set(LIBYANG_MAJOR_SOVERSION 1)
31-
set(LIBYANG_MINOR_SOVERSION 5)
32-
set(LIBYANG_MICRO_SOVERSION 5)
31+
set(LIBYANG_MINOR_SOVERSION 6)
32+
set(LIBYANG_MICRO_SOVERSION 7)
3333
set(LIBYANG_SOVERSION_FULL ${LIBYANG_MAJOR_SOVERSION}.${LIBYANG_MINOR_SOVERSION}.${LIBYANG_MICRO_SOVERSION})
3434
set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_SOVERSION})
3535

FindYANG.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ else ()
7070
${CMAKE_INSTALL_PREFIX}/lib
7171
)
7272

73-
if ()
73+
if (LIBYANG_INCLUDE_DIR AND LIBYANG_LIBRARY)
7474
set(LIBYANG_FOUND TRUE)
7575
else ()
7676
set(LIBYANG_FOUND FALSE)

packages/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${CPP_PACKAGE}-dev.install
2626
#configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PYTHON_PACKAGE}.install
2727
# ${PROJECT_BINARY_DIR}/build-packages/debian.${PYTHON_PACKAGE}.install COPYONLY)
2828

29-
if (NOT DEB_BUILDER)
29+
if(NOT DEB_BUILDER)
3030
message(STATUS "Missing tools (devscripts, debhelper package) for building DEB package.")
31-
else ()
31+
else()
3232
# target for local build deb package
3333
message(STATUS "To build local DEB package, use \"build-deb\" target.")
3434
add_custom_target(build-deb
@@ -38,9 +38,9 @@ else ()
3838
configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY)
3939
endif()
4040

41-
if (NOT RPM_BUILDER)
41+
if(NOT RPM_BUILDER)
4242
message(STATUS "Missing tools (rpm package) for building RPM package.")
43-
else ()
43+
else()
4444
# target for local build rpm package
4545
message(STATUS "To build local RPM package, use \"build-rpm\" target.")
4646
string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR})

src/common.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,12 +1305,6 @@ ly_new_node_validity(const struct lys_node *schema)
13051305

13061306
validity = LYD_VAL_OK;
13071307

1308-
if (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
1309-
if (((struct lys_node_leaf *)schema)->type.base == LY_TYPE_LEAFREF) {
1310-
/* leafref target validation */
1311-
validity |= LYD_VAL_LEAFREF;
1312-
}
1313-
}
13141308
if (schema->nodetype & (LYS_LEAFLIST | LYS_LIST)) {
13151309
/* duplicit instance check */
13161310
validity |= LYD_VAL_DUP;

src/common.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ extern THREAD_LOCAL enum int_log_opts log_opt;
102102
*/
103103
extern volatile uint8_t ly_log_level;
104104
extern volatile uint8_t ly_log_opts;
105+
extern volatile int ly_log_dbg_groups;
105106

106107
void ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, const char *format, ...);
107108

src/context.c

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,6 @@ ctx_modules_undo_backlinks(struct ly_ctx *ctx, struct ly_set *mods)
11121112
uint8_t j;
11131113
unsigned int u, v;
11141114
struct lys_module *mod;
1115-
struct lys_node *elem, *next;
1116-
struct lys_node_leaf *leaf;
11171115

11181116
/* maintain backlinks (start with internal ietf-yang-library which have leafs as possible targets of leafrefs */
11191117
for (o = ctx->internal_module_count - 1; o < ctx->models.used; o++) {
@@ -1156,54 +1154,6 @@ ctx_modules_undo_backlinks(struct ly_ctx *ctx, struct ly_set *mods)
11561154
mod->ident[u].der = NULL;
11571155
}
11581156
}
1159-
1160-
/* 3) leafrefs */
1161-
for (elem = next = mod->data; elem; elem = next) {
1162-
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
1163-
leaf = (struct lys_node_leaf *)elem; /* shortcut */
1164-
if (leaf->backlinks) {
1165-
if (!mods) {
1166-
/* remove all backlinks */
1167-
ly_set_free(leaf->backlinks);
1168-
leaf->backlinks = NULL;
1169-
} else {
1170-
for (v = 0; v < leaf->backlinks->number; v++) {
1171-
if (ly_set_contains(mods, leaf->backlinks->set.s[v]->module) != -1) {
1172-
/* derived identity is in module to remove */
1173-
ly_set_rm_index(leaf->backlinks, v);
1174-
v--;
1175-
}
1176-
}
1177-
if (!leaf->backlinks->number) {
1178-
/* all backlinks removed */
1179-
ly_set_free(leaf->backlinks);
1180-
leaf->backlinks = NULL;
1181-
}
1182-
}
1183-
}
1184-
}
1185-
1186-
/* select next element to process */
1187-
next = elem->child;
1188-
/* child exception for leafs, leaflists, anyxml and groupings */
1189-
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA | LYS_GROUPING)) {
1190-
next = NULL;
1191-
}
1192-
if (!next) {
1193-
/* no children, try siblings */
1194-
next = elem->next;
1195-
}
1196-
while (!next) {
1197-
/* parent is already processed, go to its sibling */
1198-
elem = lys_parent(elem);
1199-
if (!elem) {
1200-
/* we are done, no next element to process */
1201-
break;
1202-
}
1203-
/* no siblings, go back through parents */
1204-
next = elem->next;
1205-
}
1206-
}
12071157
}
12081158
}
12091159

@@ -1212,8 +1162,6 @@ ctx_modules_redo_backlinks(struct ly_set *mods)
12121162
{
12131163
unsigned int i, j, k, s;
12141164
struct lys_module *mod;
1215-
struct lys_node *next, *elem;
1216-
struct lys_type *type;
12171165
struct lys_feature *feat;
12181166

12191167
for (i = 0; i < mods->number; ++i) {
@@ -1241,49 +1189,6 @@ ctx_modules_redo_backlinks(struct ly_set *mods)
12411189
}
12421190
}
12431191
}
1244-
1245-
/* leafrefs */
1246-
LY_TREE_DFS_BEGIN(mod->data, next, elem) {
1247-
if (elem->nodetype == LYS_GROUPING) {
1248-
goto next_sibling;
1249-
}
1250-
1251-
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
1252-
type = &((struct lys_node_leaf *)elem)->type; /* shortcut */
1253-
if (type->base == LY_TYPE_LEAFREF) {
1254-
lys_leaf_add_leafref_target(type->info.lref.target, elem);
1255-
}
1256-
}
1257-
1258-
/* select element for the next run - children first */
1259-
next = elem->child;
1260-
1261-
/* child exception for leafs, leaflists and anyxml without children */
1262-
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) {
1263-
next = NULL;
1264-
}
1265-
if (!next) {
1266-
next_sibling:
1267-
/* no children */
1268-
if (elem == mod->data) {
1269-
/* we are done, (START) has no children */
1270-
break;
1271-
}
1272-
/* try siblings */
1273-
next = elem->next;
1274-
}
1275-
while (!next) {
1276-
/* parent is already processed, go to its sibling */
1277-
elem = lys_parent(elem);
1278-
1279-
/* no siblings, go back through parents */
1280-
if (lys_parent(elem) == lys_parent(mod->data)) {
1281-
/* we are done, no next element to process */
1282-
break;
1283-
}
1284-
next = elem->next;
1285-
}
1286-
}
12871192
}
12881193

12891194
return 0;
@@ -1522,7 +1427,7 @@ lys_set_enabled(const struct lys_module *module)
15221427
ly_set_add(disabled, mod, 0);
15231428
}
15241429

1525-
/* maintain backlinks (start with internal ietf-yang-library which have leafs as possible targets of leafrefs */
1430+
/* maintain backlinks */
15261431
ctx_modules_redo_backlinks(mods);
15271432

15281433
/* re-apply the deviations and augments */

src/hash_table.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ lyht_find_next(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p
606606
return 1;
607607
}
608608

609+
#ifndef NDEBUG
610+
609611
/* prints little-endian numbers, will also work on big-endian just the values will look weird */
610612
static char *
611613
lyht_dbgprint_val2str(void *val_p, int32_t hits, uint16_t rec_size)
@@ -627,14 +629,17 @@ lyht_dbgprint_val2str(void *val_p, int32_t hits, uint16_t rec_size)
627629
return val;
628630
}
629631

632+
#endif
633+
630634
static void
631635
lyht_dbgprint_ht(struct hash_table *ht, const char *info)
632636
{
637+
#ifndef NDEBUG
633638
struct ht_rec *rec;
634639
uint32_t i, i_len;
635640
char *val;
636641

637-
if (LY_LLDBG > ly_log_level) {
642+
if ((LY_LLDBG > ly_log_level) || !(ly_log_dbg_groups & LY_LDGHASH)) {
638643
return;
639644
}
640645

@@ -659,18 +664,29 @@ lyht_dbgprint_ht(struct hash_table *ht, const char *info)
659664
free(val);
660665
}
661666
LOGDBG(LY_LDGHASH, "");
667+
#else
668+
(void)ht;
669+
(void)info;
670+
#endif
662671
}
663672

664673
static void
665674
lyht_dbgprint_value(void *val_p, uint32_t hash, uint16_t rec_size, const char *operation)
666675
{
667-
if (LY_LLDBG > ly_log_level) {
676+
#ifndef NDEBUG
677+
if ((LY_LLDBG > ly_log_level) || !(ly_log_dbg_groups & LY_LDGHASH)) {
668678
return;
669679
}
670680

671681
char *val = lyht_dbgprint_val2str(val_p, 1, rec_size);
672682
LOGDBG(LY_LDGHASH, "%s value %s with hash %u", operation, val, hash);
673683
free(val);
684+
#else
685+
(void)val_p;
686+
(void)hash;
687+
(void)rec_size;
688+
(void)operation;
689+
#endif
674690
}
675691

676692
int

src/log.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ volatile uint8_t ly_log_level = LY_LLWRN;
3131
volatile uint8_t ly_log_opts = LY_LOLOG | LY_LOSTORE_LAST;
3232
static void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
3333
static volatile int path_flag = 1;
34-
#ifndef NDEBUG
3534
volatile int ly_log_dbg_groups = 0;
36-
#endif
3735

3836
API LY_LOG_LEVEL
3937
ly_verb(LY_LOG_LEVEL level)

src/parser.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,10 +1913,19 @@ lyp_parse_value(struct lys_type *type, const char **value_, struct lyxml_elem *x
19131913
if (xml) {
19141914
/* in case it should resolve into a instance-identifier, we can only do the JSON conversion here */
19151915
ly_ilo_change(NULL, ILO_IGNORE, &prev_ilo, NULL);
1916-
val->string = transform_xml2json(ctx, value, xml, 1, 1);
1916+
value = transform_xml2json(ctx, value, xml, 1, 1);
19171917
ly_ilo_restore(NULL, prev_ilo, NULL, 0);
1918-
if (!val->string) {
1919-
/* invalid instance-identifier format, likely some other type */
1918+
1919+
/* update the changed value */
1920+
if (value) {
1921+
lydict_remove(ctx, *value_);
1922+
*value_ = value;
1923+
} else {
1924+
value = *value_;
1925+
}
1926+
1927+
if (store) {
1928+
/* store the (unresolved) result */
19201929
val->string = lydict_insert(ctx, value, 0);
19211930
}
19221931
}
@@ -2993,6 +3002,12 @@ lyp_check_import(struct lys_module *module, const char *value, struct lys_import
29933002
return -1;
29943003
}
29953004

3005+
if ((module->version < 2) && imp->rev[0] && (imp->module->version == 2)) {
3006+
LOGERR(ctx, LY_EVALID, "YANG 1.0 module \"%s\" import with revision of YANG 1.1 module \"%s\".",
3007+
module->name, imp->module->name);
3008+
return -1;
3009+
}
3010+
29963011
if (dup) {
29973012
/* check the revisions */
29983013
if ((dup != imp->module) ||

src/parser_json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ lyd_parse_json(struct ly_ctx *ctx, const char *data, int options, const struct l
15301530
result = reply_top;
15311531
}
15321532

1533-
if (!result) {
1533+
if (!result && (options & LYD_OPT_STRICT)) {
15341534
LOGERR(ctx, LY_EVALID, "Model for the data to be linked with not found.");
15351535
goto error;
15361536
}

0 commit comments

Comments
 (0)