Skip to content

Commit 11ae1ff

Browse files
committed
log BUGFIX correctly get top-level node module
Fixes #690
1 parent 0ef0e8e commit 11ae1ff

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/log.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ ly_vlog_build_path(enum LY_VLOG_ELEM elem_type, const void *elem, char **path, i
523523
{
524524
int i, j, yang_data_extension = 0;
525525
struct lys_node_list *slist;
526-
struct lys_node *sparent = NULL;
526+
struct lys_node *sparent;
527527
struct lyd_node *dlist, *diter;
528528
const struct lys_module *top_smodule = NULL;
529529
const char *name, *prefix = NULL, *val_end, *val_start, *ext_name;
@@ -544,12 +544,14 @@ ly_vlog_build_path(enum LY_VLOG_ELEM elem_type, const void *elem, char **path, i
544544
elem = ((struct lyxml_elem *)elem)->parent;
545545
break;
546546
case LY_VLOG_LYS:
547-
if (!top_smodule && !schema_all_prefixes) {
547+
if (!top_smodule) {
548548
/* remember the top module, it will act as the current module */
549-
top_smodule = lys_node_module((struct lys_node *)elem);
549+
for (sparent = (struct lys_node *)elem; lys_parent(sparent); sparent = lys_parent(sparent));
550+
top_smodule = lys_node_module(sparent);
550551
}
551552

552-
if (!((struct lys_node *)elem)->parent || lys_node_module((struct lys_node *)elem) != top_smodule) {
553+
if (!((struct lys_node *)elem)->parent || (lys_node_module((struct lys_node *)elem) != top_smodule)
554+
|| schema_all_prefixes) {
553555
prefix = lys_node_module((struct lys_node *)elem)->name;
554556
} else {
555557
prefix = NULL;

src/tree_schema.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4995,7 +4995,7 @@ lys_path(const struct lys_node *node, int options)
49954995
return NULL;
49964996
}
49974997

4998-
if (ly_vlog_build_path(LY_VLOG_LYS, node, &buf, !options, 0)) {
4998+
if (ly_vlog_build_path(LY_VLOG_LYS, node, &buf, (options & LYS_PATH_FIRST_PREFIX) ? 0 : 1, 0)) {
49994999
return NULL;
50005000
}
50015001

0 commit comments

Comments
 (0)