]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: use flag from new libyang version to simplify the code 4088/head
authorRenato Westphal <renato@opensourcerouting.org>
Sat, 13 Apr 2019 00:38:57 +0000 (21:38 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 2 Jul 2019 14:32:06 +0000 (11:32 -0300)
When using the LYD_PATH_OPT_NOPARENTRET flag, lyd_new_path() returns
the path-referenced node instead of the first created node. This
flag wasn't available in libyang 0.16-r1 so we couldn't use it
before. Use it now to simplify the code where possible.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/northbound.c

index 8a5cd0ef14db39012978d2f21720d6330ec3a235..4478abf5a753af8a4fbdd782a3731a67b6a6967e 100644 (file)
@@ -1383,19 +1383,12 @@ int nb_oper_data_iterate(const char *xpath, struct yang_translator *translator,
         */
        ly_errno = 0;
        dnode = lyd_new_path(NULL, ly_native_ctx, xpath, NULL, 0,
-                            LYD_PATH_OPT_UPDATE);
-       if (!dnode && ly_errno) {
+                            LYD_PATH_OPT_UPDATE | LYD_PATH_OPT_NOPARENTRET);
+       if (!dnode) {
                flog_warn(EC_LIB_LIBYANG, "%s: lyd_new_path() failed",
                          __func__);
                return NB_ERR;
        }
-       /*
-        * We can remove the following two lines once we depend on
-        * libyang-v0.16-r2, which has the LYD_PATH_OPT_NOPARENTRET flag for
-        * lyd_new_path().
-        */
-       dnode = yang_dnode_get(dnode, xpath);
-       assert(dnode);
 
        /*
         * Create a linked list to sort the data nodes starting from the root.