From 04d5f52d906247a3acc8727db457cc4817887a6f Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 19 Apr 2023 10:45:21 +0200 Subject: [PATCH] Revert Temporar fix in clixon_custom.h: XPATH_CANONICAL_SKIP_CHECK --- include/clixon_custom.h | 6 ------ lib/src/clixon_xpath.c | 25 +++++++++++++------------ test/test_xpath_canonical.sh | 5 ++--- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/clixon_custom.h b/include/clixon_custom.h index 80cc94c9..b51b3216 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -201,9 +201,3 @@ * Introduced in 6.1, remove in 6.2 */ #define AUTOCLI_DEPRECATED_HIDE - -/*! Temporar fix for xpath_traverse_canonical for yang schema mount - * Must rewrite function to handle mountpoints, now just ignore errors - * See also - */ -#define XPATH_CANONICAL_SKIP_CHECK diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index e1811830..d3408c83 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -1005,7 +1005,6 @@ xpath_traverse_canonical(xpath_tree *xs, goto fail; } if ((ymod = yang_find_module_by_namespace(yspec, namespace)) == NULL){ -#ifndef XPATH_CANONICAL_SKIP_CHECK if ((cb = cbuf_new()) == NULL){ clicon_err(OE_UNIX, errno, "cbuf_new"); goto done; @@ -1014,20 +1013,22 @@ xpath_traverse_canonical(xpath_tree *xs, if (reason) *reason = cb; goto fail; -#endif } - if (ymod == NULL) +#if 0 /* safe-catch if previous check is not considered as an error */ + if (ymod == NULL) prefix1 = prefix0; - else if ((prefix1 = yang_find_myprefix(ymod)) == NULL){ - if ((cb = cbuf_new()) == NULL){ - clicon_err(OE_UNIX, errno, "cbuf_new"); - goto done; + else +#endif + if ((prefix1 = yang_find_myprefix(ymod)) == NULL){ + if ((cb = cbuf_new()) == NULL){ + clicon_err(OE_UNIX, errno, "cbuf_new"); + goto done; + } + cprintf(cb, "No prefix found in module: %s", yang_argument_get(ymod)); + if (reason) + *reason = cb; + goto fail; } - cprintf(cb, "No prefix found in module: %s", yang_argument_get(ymod)); - if (reason) - *reason = cb; - goto fail; - } if (xml_nsctx_get(nsc1, prefix1) == NULL) if (xml_nsctx_add(nsc1, prefix1, namespace) < 0) goto done; diff --git a/test/test_xpath_canonical.sh b/test/test_xpath_canonical.sh index 7735fa00..9e8fb733 100755 --- a/test/test_xpath_canonical.sh +++ b/test/test_xpath_canonical.sh @@ -59,9 +59,8 @@ expectpart "$($clixon_util_xpath -c -y $ydir -p "//x[.='42']" -n null:urn:exampl new "xpath canonical form (no default should fail)" expectpart "$($clixon_util_xpath -c -y $ydir -p /x/j:y -n i:urn:example:a -n j:urn:example:b 2>&1)" 0 "/x/j:y: No namespace found for prefix" -# comment as long as XPATH_CANONICAL_SKIP_CHECK -#new "xpath canonical form (wrong namespace should fail)" -#expectpart "$($clixon_util_xpath -c -y $ydir -p /i:x/j:y -n i:urn:example:c -n j:urn:example:b 2>&1)" 0 "/i:x/j:y: No yang found for namespace" +new "xpath canonical form (wrong namespace should fail)" +expectpart "$($clixon_util_xpath -c -y $ydir -p /i:x/j:y -n i:urn:example:c -n j:urn:example:b 2>&1)" 0 "/i:x/j:y: No yang found for namespace" rm -rf $dir