Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed Feb 3, 2020
2 parents d90f52e + 2b677b8 commit 1b7d73d
Show file tree
Hide file tree
Showing 39 changed files with 1,570 additions and 1,969 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ set(CMAKE_MACOSX_RPATH TRUE)
# micro version is changed with a set of small changes or bugfixes anywhere in the project.
set(LIBYANG_MAJOR_VERSION 1)
set(LIBYANG_MINOR_VERSION 0)
set(LIBYANG_MICRO_VERSION 109)
set(LIBYANG_MICRO_VERSION 130)
set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION})

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

Expand Down
2 changes: 1 addition & 1 deletion FindYANG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ else ()
${CMAKE_INSTALL_PREFIX}/lib
)

if ()
if (LIBYANG_INCLUDE_DIR AND LIBYANG_LIBRARY)
set(LIBYANG_FOUND TRUE)
else ()
set(LIBYANG_FOUND FALSE)
Expand Down
8 changes: 4 additions & 4 deletions packages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${CPP_PACKAGE}-dev.install
#configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PYTHON_PACKAGE}.install
# ${PROJECT_BINARY_DIR}/build-packages/debian.${PYTHON_PACKAGE}.install COPYONLY)

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

if (NOT RPM_BUILDER)
if(NOT RPM_BUILDER)
message(STATUS "Missing tools (rpm package) for building RPM package.")
else ()
else()
# target for local build rpm package
message(STATUS "To build local RPM package, use \"build-rpm\" target.")
string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR})
Expand Down
6 changes: 0 additions & 6 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,12 +1305,6 @@ ly_new_node_validity(const struct lys_node *schema)

validity = LYD_VAL_OK;

if (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
if (((struct lys_node_leaf *)schema)->type.base == LY_TYPE_LEAFREF) {
/* leafref target validation */
validity |= LYD_VAL_LEAFREF;
}
}
if (schema->nodetype & (LYS_LEAFLIST | LYS_LIST)) {
/* duplicit instance check */
validity |= LYD_VAL_DUP;
Expand Down
1 change: 1 addition & 0 deletions src/common.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ extern THREAD_LOCAL enum int_log_opts log_opt;
*/
extern volatile uint8_t ly_log_level;
extern volatile uint8_t ly_log_opts;
extern volatile int ly_log_dbg_groups;

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

Expand Down
97 changes: 1 addition & 96 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,6 @@ ctx_modules_undo_backlinks(struct ly_ctx *ctx, struct ly_set *mods)
uint8_t j;
unsigned int u, v;
struct lys_module *mod;
struct lys_node *elem, *next;
struct lys_node_leaf *leaf;

/* maintain backlinks (start with internal ietf-yang-library which have leafs as possible targets of leafrefs */
for (o = ctx->internal_module_count - 1; o < ctx->models.used; o++) {
Expand Down Expand Up @@ -1156,54 +1154,6 @@ ctx_modules_undo_backlinks(struct ly_ctx *ctx, struct ly_set *mods)
mod->ident[u].der = NULL;
}
}

/* 3) leafrefs */
for (elem = next = mod->data; elem; elem = next) {
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
leaf = (struct lys_node_leaf *)elem; /* shortcut */
if (leaf->backlinks) {
if (!mods) {
/* remove all backlinks */
ly_set_free(leaf->backlinks);
leaf->backlinks = NULL;
} else {
for (v = 0; v < leaf->backlinks->number; v++) {
if (ly_set_contains(mods, leaf->backlinks->set.s[v]->module) != -1) {
/* derived identity is in module to remove */
ly_set_rm_index(leaf->backlinks, v);
v--;
}
}
if (!leaf->backlinks->number) {
/* all backlinks removed */
ly_set_free(leaf->backlinks);
leaf->backlinks = NULL;
}
}
}
}

/* select next element to process */
next = elem->child;
/* child exception for leafs, leaflists, anyxml and groupings */
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA | LYS_GROUPING)) {
next = NULL;
}
if (!next) {
/* no children, try siblings */
next = elem->next;
}
while (!next) {
/* parent is already processed, go to its sibling */
elem = lys_parent(elem);
if (!elem) {
/* we are done, no next element to process */
break;
}
/* no siblings, go back through parents */
next = elem->next;
}
}
}
}

Expand All @@ -1212,8 +1162,6 @@ ctx_modules_redo_backlinks(struct ly_set *mods)
{
unsigned int i, j, k, s;
struct lys_module *mod;
struct lys_node *next, *elem;
struct lys_type *type;
struct lys_feature *feat;

for (i = 0; i < mods->number; ++i) {
Expand Down Expand Up @@ -1241,49 +1189,6 @@ ctx_modules_redo_backlinks(struct ly_set *mods)
}
}
}

/* leafrefs */
LY_TREE_DFS_BEGIN(mod->data, next, elem) {
if (elem->nodetype == LYS_GROUPING) {
goto next_sibling;
}

if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
type = &((struct lys_node_leaf *)elem)->type; /* shortcut */
if (type->base == LY_TYPE_LEAFREF) {
lys_leaf_add_leafref_target(type->info.lref.target, elem);
}
}

/* select element for the next run - children first */
next = elem->child;

/* child exception for leafs, leaflists and anyxml without children */
if (elem->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) {
next = NULL;
}
if (!next) {
next_sibling:
/* no children */
if (elem == mod->data) {
/* we are done, (START) has no children */
break;
}
/* try siblings */
next = elem->next;
}
while (!next) {
/* parent is already processed, go to its sibling */
elem = lys_parent(elem);

/* no siblings, go back through parents */
if (lys_parent(elem) == lys_parent(mod->data)) {
/* we are done, no next element to process */
break;
}
next = elem->next;
}
}
}

return 0;
Expand Down Expand Up @@ -1522,7 +1427,7 @@ lys_set_enabled(const struct lys_module *module)
ly_set_add(disabled, mod, 0);
}

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

/* re-apply the deviations and augments */
Expand Down
20 changes: 18 additions & 2 deletions src/hash_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ lyht_find_next(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p
return 1;
}

#ifndef NDEBUG

/* prints little-endian numbers, will also work on big-endian just the values will look weird */
static char *
lyht_dbgprint_val2str(void *val_p, int32_t hits, uint16_t rec_size)
Expand All @@ -627,14 +629,17 @@ lyht_dbgprint_val2str(void *val_p, int32_t hits, uint16_t rec_size)
return val;
}

#endif

static void
lyht_dbgprint_ht(struct hash_table *ht, const char *info)
{
#ifndef NDEBUG
struct ht_rec *rec;
uint32_t i, i_len;
char *val;

if (LY_LLDBG > ly_log_level) {
if ((LY_LLDBG > ly_log_level) || !(ly_log_dbg_groups & LY_LDGHASH)) {
return;
}

Expand All @@ -659,18 +664,29 @@ lyht_dbgprint_ht(struct hash_table *ht, const char *info)
free(val);
}
LOGDBG(LY_LDGHASH, "");
#else
(void)ht;
(void)info;
#endif
}

static void
lyht_dbgprint_value(void *val_p, uint32_t hash, uint16_t rec_size, const char *operation)
{
if (LY_LLDBG > ly_log_level) {
#ifndef NDEBUG
if ((LY_LLDBG > ly_log_level) || !(ly_log_dbg_groups & LY_LDGHASH)) {
return;
}

char *val = lyht_dbgprint_val2str(val_p, 1, rec_size);
LOGDBG(LY_LDGHASH, "%s value %s with hash %u", operation, val, hash);
free(val);
#else
(void)val_p;
(void)hash;
(void)rec_size;
(void)operation;
#endif
}

int
Expand Down
2 changes: 0 additions & 2 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ volatile uint8_t ly_log_level = LY_LLWRN;
volatile uint8_t ly_log_opts = LY_LOLOG | LY_LOSTORE_LAST;
static void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
static volatile int path_flag = 1;
#ifndef NDEBUG
volatile int ly_log_dbg_groups = 0;
#endif

API LY_LOG_LEVEL
ly_verb(LY_LOG_LEVEL level)
Expand Down
21 changes: 18 additions & 3 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,10 +1913,19 @@ lyp_parse_value(struct lys_type *type, const char **value_, struct lyxml_elem *x
if (xml) {
/* in case it should resolve into a instance-identifier, we can only do the JSON conversion here */
ly_ilo_change(NULL, ILO_IGNORE, &prev_ilo, NULL);
val->string = transform_xml2json(ctx, value, xml, 1, 1);
value = transform_xml2json(ctx, value, xml, 1, 1);
ly_ilo_restore(NULL, prev_ilo, NULL, 0);
if (!val->string) {
/* invalid instance-identifier format, likely some other type */

/* update the changed value */
if (value) {
lydict_remove(ctx, *value_);
*value_ = value;
} else {
value = *value_;
}

if (store) {
/* store the (unresolved) result */
val->string = lydict_insert(ctx, value, 0);
}
}
Expand Down Expand Up @@ -2993,6 +3002,12 @@ lyp_check_import(struct lys_module *module, const char *value, struct lys_import
return -1;
}

if ((module->version < 2) && imp->rev[0] && (imp->module->version == 2)) {
LOGERR(ctx, LY_EVALID, "YANG 1.0 module \"%s\" import with revision of YANG 1.1 module \"%s\".",
module->name, imp->module->name);
return -1;
}

if (dup) {
/* check the revisions */
if ((dup != imp->module) ||
Expand Down
2 changes: 1 addition & 1 deletion src/parser_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ lyd_parse_json(struct ly_ctx *ctx, const char *data, int options, const struct l
result = reply_top;
}

if (!result) {
if (!result && (options & LYD_OPT_STRICT)) {
LOGERR(ctx, LY_EVALID, "Model for the data to be linked with not found.");
goto error;
}
Expand Down
16 changes: 8 additions & 8 deletions src/parser_lyb.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ lyb_parse_model(const char *data, const struct lys_module **mod, int options, st
}

static struct lyd_node *
lyb_new_node(const struct lys_node *schema)
lyb_new_node(const struct lys_node *schema, int options)
{
struct lyd_node *node;

Expand All @@ -312,10 +312,6 @@ lyb_new_node(const struct lys_node *schema)
case LYS_LEAF:
case LYS_LEAFLIST:
node = calloc(sizeof(struct lyd_node_leaf_list), 1);

if (((struct lys_node_leaf *)schema)->type.base == LY_TYPE_LEAFREF) {
node->validity |= LYD_VAL_LEAFREF;
}
break;
case LYS_ANYDATA:
case LYS_ANYXML:
Expand All @@ -329,8 +325,12 @@ lyb_new_node(const struct lys_node *schema)
/* fill basic info */
node->schema = (struct lys_node *)schema;
if (resolve_applies_when(schema, 0, NULL)) {
/* this data are considered trusted so if this node exists, it means its when must have been true */
node->when_status = LYD_WHEN | LYD_WHEN_TRUE;
node->when_status = LYD_WHEN;

if (options & LYD_OPT_TRUSTED) {
/* this data are considered trusted so if this node exists, it means its when must have been true */
node->when_status |= LYD_WHEN_TRUE;
}
}
node->prev = node;

Expand Down Expand Up @@ -1061,7 +1061,7 @@ lyb_parse_subtree(const char *data, struct lyd_node *parent, struct lyd_node **f
/*
* read the node
*/
node = lyb_new_node(snode);
node = lyb_new_node(snode, options);
if (!node) {
goto error;
}
Expand Down
Loading

0 comments on commit 1b7d73d

Please sign in to comment.