]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: set YANG search directory when creating libyang context
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 16 Nov 2018 13:13:48 +0000 (11:13 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 26 Nov 2018 15:07:40 +0000 (13:07 -0200)
Minor code simplification.

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

index a7a50a46b0fcb225aff52c24217e96cda2083ad1..6236dc5a6696ec7ebe6d85c5b7e6ac5eebe533ca 100644 (file)
@@ -609,13 +609,13 @@ void yang_init(void)
        ly_log_options(LY_LOLOG | LY_LOSTORE);
 
        /* Initialize libyang container for native models. */
-       ly_native_ctx = ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIR_CWD);
+       ly_native_ctx =
+               ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD);
        if (!ly_native_ctx) {
                flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
                exit(1);
        }
        ly_ctx_set_module_imp_clb(ly_native_ctx, yang_module_imp_clb, NULL);
-       ly_ctx_set_searchdir(ly_native_ctx, YANG_MODELS_PATH);
        ly_ctx_set_priv_dup_clb(ly_native_ctx, ly_dup_cb);
 
        /* Detect if the required libyang plugin(s) were loaded successfully. */
index 27b92a0e6bf8878e60798a0e4736e1e457ccdd89..02da3ebd6af4254ff7ed7cbb281dcaf94ca3853a 100644 (file)
@@ -162,12 +162,12 @@ struct yang_translator *yang_translator_load(const char *path)
        RB_INSERT(yang_translators, &yang_translators, translator);
 
        /* Initialize the translator libyang context. */
-       translator->ly_ctx = ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIR_CWD);
+       translator->ly_ctx =
+               ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD);
        if (!translator->ly_ctx) {
                flog_warn(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
                goto error;
        }
-       ly_ctx_set_searchdir(translator->ly_ctx, YANG_MODELS_PATH);
 
        /* Load modules and deviations. */
        set = lyd_find_path(dnode, "./module");
@@ -515,12 +515,12 @@ static void str_replace(char *o_string, const char *s_string,
 
 void yang_translator_init(void)
 {
-       ly_translator_ctx = ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIR_CWD);
+       ly_translator_ctx =
+               ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD);
        if (!ly_translator_ctx) {
                flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
                exit(1);
        }
-       ly_ctx_set_searchdir(ly_translator_ctx, YANG_MODELS_PATH);
 
        if (!ly_ctx_load_module(ly_translator_ctx, "frr-module-translator",
                                NULL)) {