@@ -540,26 +540,25 @@ node_has_printable_meta(const struct lyd_node *node)
540540static LY_ERR
541541json_print_attributes (struct jsonpr_ctx * pctx , const struct lyd_node * node , ly_bool inner )
542542{
543- const struct lys_module * df_mod = NULL ;
543+ const struct lys_module * wd_mod = NULL ;
544544
545545 if (node -> schema && (node -> schema -> nodetype != LYS_CONTAINER ) && (((node -> flags & LYD_DEFAULT ) &&
546546 (pctx -> options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG ))) ||
547547 ((pctx -> options & LYD_PRINT_WD_ALL_TAG ) && lyd_is_default (node )))) {
548- /* we have implicit OR explicit default node, print only if we have with-defaults module */
549- if (ly_ctx_get_module_implemented (LYD_CTX (node ), "ietf-netconf-with-defaults" )) {
550- df_mod = ly_ctx_get_module_implemented (LYD_CTX (node ), "default" );
551- }
548+ /* we have implicit OR explicit default node, print only if we have with-defaults module
549+ * (module name according to https://datatracker.ietf.org/doc/html/rfc8040#page-60) */
550+ wd_mod = ly_ctx_get_module_implemented (LYD_CTX (node ), "ietf-netconf-with-defaults" );
552551 }
553552
554- if (node -> schema && (df_mod || node_has_printable_meta (node ))) {
553+ if (node -> schema && (wd_mod || node_has_printable_meta (node ))) {
555554 if (inner ) {
556555 LY_CHECK_RET (json_print_member2 (pctx , node -> parent , LY_VALUE_JSON , NULL , 1 ));
557556 } else {
558557 LY_CHECK_RET (json_print_member (pctx , node , NULL , 1 ));
559558 }
560559 ly_print_ (pctx -> out , "{%s" , (DO_FORMAT ? "\n" : "" ));
561560 LEVEL_INC ;
562- LY_CHECK_RET (json_print_metadata (pctx , node , df_mod ));
561+ LY_CHECK_RET (json_print_metadata (pctx , node , wd_mod ));
563562 LEVEL_DEC ;
564563 ly_print_ (pctx -> out , "%s%*s}" , DO_FORMAT ? "\n" : "" , INDENT );
565564 LEVEL_PRINTED ;
@@ -832,7 +831,7 @@ json_print_array_is_last_inst(struct jsonpr_ctx *pctx, const struct lyd_node *no
832831static LY_ERR
833832json_print_leaf_list (struct jsonpr_ctx * pctx , const struct lyd_node * node )
834833{
835- const struct lys_module * df_mod = NULL ;
834+ const struct lys_module * wd_mod = NULL ;
836835
837836 if (!is_open_array (pctx , node )) {
838837 LY_CHECK_RET (json_print_member (pctx , node , NULL , 0 ));
@@ -856,11 +855,9 @@ json_print_leaf_list(struct jsonpr_ctx *pctx, const struct lyd_node *node)
856855 if (((node -> flags & LYD_DEFAULT ) && (pctx -> options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG ))) ||
857856 ((pctx -> options & LYD_PRINT_WD_ALL_TAG ) && lyd_is_default (node ))) {
858857 /* we have implicit OR explicit default node, print only if we have with-defaults module */
859- if (ly_ctx_get_module_implemented (LYD_CTX (node ), "ietf-netconf-with-defaults" )) {
860- df_mod = ly_ctx_get_module_implemented (LYD_CTX (node ), "default" );
861- }
858+ wd_mod = ly_ctx_get_module_implemented (LYD_CTX (node ), "ietf-netconf-with-defaults" );
862859 }
863- if (df_mod || node_has_printable_meta (node )) {
860+ if (wd_mod || node_has_printable_meta (node )) {
864861 /* we will be printing metadata for these siblings */
865862 pctx -> first_leaflist = node ;
866863 }
@@ -913,16 +910,14 @@ static LY_ERR
913910json_print_meta_attr_leaflist (struct jsonpr_ctx * pctx )
914911{
915912 const struct lyd_node * prev , * node , * iter ;
916- const struct lys_module * df_mod = NULL , * iter_dfmod ;
913+ const struct lys_module * wd_mod = NULL , * iter_wdmod ;
917914 const struct lyd_node_opaq * opaq = NULL ;
918915
919916 assert (pctx -> first_leaflist );
920917
921918 if (pctx -> options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG )) {
922919 /* we have implicit OR explicit default node, print only if we have with-defaults module */
923- if (ly_ctx_get_module_implemented (pctx -> ctx , "ietf-netconf-with-defaults" )) {
924- df_mod = ly_ctx_get_module_implemented (pctx -> ctx , "default" );
925- }
920+ wd_mod = ly_ctx_get_module_implemented (pctx -> ctx , "ietf-netconf-with-defaults" );
926921 }
927922
928923 /* node is the first instance of the leaf-list */
@@ -942,16 +937,16 @@ json_print_meta_attr_leaflist(struct jsonpr_ctx *pctx)
942937 LY_LIST_FOR (node , iter ) {
943938 PRINT_COMMA ;
944939 if (iter -> schema && ((iter -> flags & LYD_DEFAULT ) || ((pctx -> options & LYD_PRINT_WD_ALL_TAG ) && lyd_is_default (iter )))) {
945- iter_dfmod = df_mod ;
940+ iter_wdmod = wd_mod ;
946941 } else {
947- iter_dfmod = NULL ;
942+ iter_wdmod = NULL ;
948943 }
949- if ((iter -> schema && (node_has_printable_meta (iter ) || iter_dfmod )) || (opaq && opaq -> attr )) {
944+ if ((iter -> schema && (node_has_printable_meta (iter ) || iter_wdmod )) || (opaq && opaq -> attr )) {
950945 ly_print_ (pctx -> out , "%*s%s" , INDENT , DO_FORMAT ? "{\n" : "{" );
951946 LEVEL_INC ;
952947
953948 if (iter -> schema ) {
954- LY_CHECK_RET (json_print_metadata (pctx , iter , iter_dfmod ));
949+ LY_CHECK_RET (json_print_metadata (pctx , iter , iter_wdmod ));
955950 } else {
956951 LY_CHECK_RET (json_print_attribute (pctx , (struct lyd_node_opaq * )iter ));
957952 }
0 commit comments