@@ -482,6 +482,7 @@ parse_path_key_expr(const char *id, const char **prefix, int *pref_len, const ch
482482 * absolute-path = 1*("/" (node-identifier *path-predicate))
483483 * relative-path = 1*(".." "/") descendant-path
484484 *
485+ * @param[in] mod Module of the context node to get correct prefix in case it is not explicitly specified
485486 * @param[in] id Identifier to use.
486487 * @param[out] prefix Points to the prefix, NULL if there is not any.
487488 * @param[out] pref_len Length of the prefix, 0 if there is not any.
@@ -496,8 +497,8 @@ parse_path_key_expr(const char *id, const char **prefix, int *pref_len, const ch
496497 * positive on success, negative on failure.
497498 */
498499static int
499- parse_path_arg (const char * id , const char * * prefix , int * pref_len , const char * * name , int * nam_len , int * parent_times ,
500- int * has_predicate )
500+ parse_path_arg (struct lys_module * mod , const char * id , const char * * prefix , int * pref_len ,
501+ const char * * name , int * nam_len , int * parent_times , int * has_predicate )
501502{
502503 int parsed = 0 , ret , par_times = 0 ;
503504
@@ -553,6 +554,11 @@ parse_path_arg(const char *id, const char **prefix, int *pref_len, const char **
553554 if ((ret = parse_node_identifier (id , prefix , pref_len , name , nam_len )) < 1 ) {
554555 return - parsed - ret ;
555556 }
557+ if (!(* prefix )) {
558+ /* actually we always need prefix even it is not specified */
559+ * prefix = lys_main_module (mod )-> name ;
560+ * pref_len = strlen (* prefix );
561+ }
556562
557563 parsed += ret ;
558564 id += ret ;
@@ -3510,7 +3516,7 @@ resolve_path_arg_data(struct lyd_node *node, const char *path, struct unres_data
35103516
35113517 /* searching for nodeset */
35123518 do {
3513- if ((i = parse_path_arg (path , & prefix , & pref_len , & name , & nam_len , & parent_times , & has_predicate )) < 1 ) {
3519+ if ((i = parse_path_arg (node -> schema -> module , path , & prefix , & pref_len , & name , & nam_len , & parent_times , & has_predicate )) < 1 ) {
35143520 LOGVAL (LYE_INCHAR , LY_VLOG_LYD , node , path [- i ], & path [- i ]);
35153521 rc = -1 ;
35163522 goto error ;
@@ -3756,7 +3762,7 @@ resolve_path_arg_schema(const char *path, struct lys_node *parent, int parent_tp
37563762
37573763 mod2 = lys_node_module (parent );
37583764 do {
3759- if ((i = parse_path_arg (id , & prefix , & pref_len , & name , & nam_len , & parent_times , & has_predicate )) < 1 ) {
3765+ if ((i = parse_path_arg (parent -> module , id , & prefix , & pref_len , & name , & nam_len , & parent_times , & has_predicate )) < 1 ) {
37603766 LOGVAL (LYE_INCHAR , parent_tpdf ? LY_VLOG_NONE : LY_VLOG_LYS , parent_tpdf ? NULL : parent , id [- i ], & id [- i ]);
37613767 return -1 ;
37623768 }
0 commit comments