@@ -165,24 +165,30 @@ nc_server_init_ctx(struct ly_ctx **ctx)
165165
166166 if (!* ctx ) {
167167 /* context not given, create a new one */
168- if (ly_ctx_new (NC_SERVER_SEARCH_DIR , 0 , ctx )) {
169- ERR (NULL , "Couldn't create new libyang context.\n " );
168+ if (ly_ctx_new (ly_yang_module_dir () , 0 , ctx )) {
169+ ERR (NULL , "Failed to create a new libyang context." );
170170 ret = 1 ;
171171 goto cleanup ;
172172 }
173173 new_ctx = 1 ;
174+
175+ if (ly_ctx_set_searchdir (* ctx , nc_yang_module_dir ())) {
176+ ERR (NULL , "Failed to set searchdir for a context." );
177+ ret = 1 ;
178+ goto cleanup ;
179+ }
174180 }
175181
176182 if (new_ctx ) {
177183 /* new context created, implement both modules */
178184 if (!ly_ctx_load_module (* ctx , "ietf-netconf" , NULL , ietf_netconf_features )) {
179- ERR (NULL , "Loading module \"ietf-netconf\" failed.\n " );
185+ ERR (NULL , "Loading module \"ietf-netconf\" failed." );
180186 ret = 1 ;
181187 goto cleanup ;
182188 }
183189
184190 if (!ly_ctx_load_module (* ctx , "ietf-netconf-monitoring" , NULL , ietf_netconf_monitoring_features )) {
185- ERR (NULL , "Loading module \"ietf-netconf-monitoring\" failed.\n " );
191+ ERR (NULL , "Loading module \"ietf-netconf-monitoring\" failed." );
186192 ret = 1 ;
187193 goto cleanup ;
188194 }
@@ -197,7 +203,7 @@ nc_server_init_ctx(struct ly_ctx **ctx)
197203 if (lys_feature_value (module , ietf_netconf_features [i ])) {
198204 /* feature not found, enable all of them */
199205 if (!ly_ctx_load_module (* ctx , "ietf-netconf" , NULL , ietf_netconf_features )) {
200- ERR (NULL , "Loading module \"ietf-netconf\" failed.\n " );
206+ ERR (NULL , "Loading module \"ietf-netconf\" failed." );
201207 ret = 1 ;
202208 goto cleanup ;
203209 }
@@ -208,7 +214,7 @@ nc_server_init_ctx(struct ly_ctx **ctx)
208214 } else {
209215 /* ietf-netconf module not found, add it */
210216 if (!ly_ctx_load_module (* ctx , "ietf-netconf" , NULL , ietf_netconf_features )) {
211- ERR (NULL , "Loading module \"ietf-netconf\" failed.\n " );
217+ ERR (NULL , "Loading module \"ietf-netconf\" failed." );
212218 ret = 1 ;
213219 goto cleanup ;
214220 }
@@ -218,7 +224,7 @@ nc_server_init_ctx(struct ly_ctx **ctx)
218224 if (!module ) {
219225 /* ietf-netconf-monitoring module not found, add it */
220226 if (!ly_ctx_load_module (* ctx , "ietf-netconf-monitoring" , NULL , ietf_netconf_monitoring_features )) {
221- ERR (NULL , "Loading module \"ietf-netconf-monitoring\" failed.\n " );
227+ ERR (NULL , "Loading module \"ietf-netconf-monitoring\" failed." );
222228 ret = 1 ;
223229 goto cleanup ;
224230 }
0 commit comments