@@ -3029,7 +3029,7 @@ resolve_superior_type(const char *name, const char *mod_name, const struct lys_m
30293029 * @return EXIT_SUCCESS on success, EXIT_FAILURE on forward reference, -1 on error.
30303030 */
30313031static int
3032- check_default (struct lys_type * type , const char * * value , struct lys_module * module )
3032+ check_default (struct lys_type * type , const char * * value , struct lys_module * module , int tpdf )
30333033{
30343034 struct lys_tpdf * base_tpdf = NULL ;
30353035 struct lyd_node_leaf_list node ;
@@ -3041,6 +3041,9 @@ check_default(struct lys_type *type, const char **value, struct lys_module *modu
30413041 if (type -> base <= LY_TYPE_DER ) {
30423042 /* the type was not resolved yet, nothing to do for now */
30433043 return EXIT_FAILURE ;
3044+ } else if (type -> base == LY_TYPE_LEAFREF && tpdf ) {
3045+ /* leafref in typedef cannot be checked */
3046+ return EXIT_SUCCESS ;
30443047 }
30453048
30463049 dflt = * value ;
@@ -3142,7 +3145,7 @@ check_default(struct lys_type *type, const char **value, struct lys_module *modu
31423145 ret = EXIT_FAILURE ;
31433146 goto finish ;
31443147 }
3145- ret = check_default (& type -> info .lref .target -> type , & dflt , module );
3148+ ret = check_default (& type -> info .lref .target -> type , & dflt , module , 0 );
31463149 if (!ret ) {
31473150 /* adopt possibly changed default value to its canonical form */
31483151 if (* value ) {
@@ -6539,10 +6542,13 @@ resolve_unres_schema_item(struct lys_module *mod, void *item, enum UNRES_ITEM ty
65396542 case UNRES_USES :
65406543 rc = resolve_unres_schema_uses (item , unres );
65416544 break ;
6545+ case UNRES_TYPEDEF_DFLT :
6546+ parent_type ++ ;
6547+ /* no break */
65426548 case UNRES_TYPE_DFLT :
65436549 stype = item ;
65446550
6545- rc = check_default (stype , (const char * * )str_snode , mod );
6551+ rc = check_default (stype , (const char * * )str_snode , mod , parent_type );
65466552 break ;
65476553 case UNRES_CHOICE_DFLT :
65486554 expr = str_snode ;
@@ -6764,6 +6770,7 @@ print_unres_schema_item_fail(void *item, enum UNRES_ITEM type, void *str_node)
67646770 case UNRES_USES :
67656771 LOGVRB ("Resolving %s \"%s\" failed, it will be attempted later." , "uses" , ((struct lys_node_uses * )item )-> name );
67666772 break ;
6773+ case UNRES_TYPEDEF_DFLT :
67676774 case UNRES_TYPE_DFLT :
67686775 if (str_node ) {
67696776 LOGVRB ("Resolving %s \"%s\" failed, it will be attempted later." , "type default" , (char * )str_node );
0 commit comments