libyang
libyang copied to clipboard
What is imp_size, imp, ident_size, ident, features_size, features fields
What are imp_size, imp, ident_size, ident, features_size, features fields in "lys_module" structure of libyang1. Why it is removed in libyang2 ? I have a code repo which usages libyang1 so does it these fields. Now I have to upgrade my code base to use libyang2. But it gives error in my code with libyang2. Can anyone explain to me what is the concept behind using these fields ? So that I can handle it in using libyang2.
Compilation error in my code while switching from libyang1 to libyang2
root@5e499b59fa8b:/opt/dev/ntsim-ng# gcc -Wall -pedantic -Isource source/core/container.c source/core/context.c source/core/docker.c source/core/framework.c source/core/test.c source/core/session.c source/core/nc_config.c source/core/app/supervisor.c source/core/app/app_common.c source/core/app/manager.c source/core/app/manager_context.c source/core/app/manager_operations.c source/core/app/manager_actions.c source/core/app/manager_sysrepo.c source/core/app/network_function.c source/core/app/nf_oran_du.c source/core/app/blank.c source/core/datastore/schema.c source/core/datastore/operations.c source/core/datastore/populate.c source/core/datastore/populate_aux.c source/core/datastore/populate_late_resolve.c source/core/datastore/populate_recursive.c source/core/datastore/populate_validation.c source/core/faults/faults.c source/core/faults/faults_counters.c source/core/faults/faults_processing.c source/core/faults/faults_logic.c source/core/faults/faults_ves.c source/utils/debug_utils.c source/utils/log_utils.c source/utils/rand_utils.c source/utils/type_utils.c source/utils/sys_utils.c source/utils/http_client.c source/utils/nts_utils.c source/utils/nc_client.c source/utils/network_emulation.c source/features/ves_pnf_registration/ves_pnf_registration.c source/features/ves_heartbeat/ves_heartbeat.c source/features/ves_file_ready/ves_file_ready.c source/features/manual_notification/manual_notification.c source/features/netconf_call_home/netconf_call_home.c source/features/web_cut_through/web_cut_through.c source/main.c -lm -lyang -lsysrepo -lnetconf2 -lcjson -lcurl -lpthread -lrt -ontsim-ng
In file included from source/core/container.c:26:
source/core/context.h:28:53: warning: 'struct lys_ident' declared inside parameter list will not be visible outside of this definition or declaration
28 | int context_get_identity_leafs_of_type(const struct lys_ident *ident, struct lys_ident ***found);
| ^~~~~~~~~
source/core/container.c: In function 'container_self_init':
source/core/container.c:58:40: warning: implicit declaration of function 'sr_get_context'; did you mean 'sr_get_content_id'? [-Wimplicit-function-declaration]
58 | session_context = (struct ly_ctx *)sr_get_context(session_connection);
| ^~~~~~~~~~~~~~
| sr_get_content_id
source/core/container.c:58:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
58 | session_context = (struct ly_ctx *)sr_get_context(session_connection);
| ^
source/core/container.c:133:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
133 | session_context = (struct ly_ctx *)sr_get_context(session_connection);
| ^
In file included from source/core/context.c:20:
source/core/context.h:28:53: warning: 'struct lys_ident' declared inside parameter list will not be visible outside of this definition or declaration
28 | int context_get_identity_leafs_of_type(const struct lys_ident *ident, struct lys_ident ***found);
| ^~~~~~~~~
In file included from source/core/context.c:21:
source/core/context.c: In function 'context_init':
source/core/context.c:65:52: error: 'struct lys_module' has no member named 'imp_size'
65 | log_add_verbose(2, " imports [%d]", module->imp_size);
| ^~
source/utils/log_utils.h:44:127: note: in definition of macro 'log_add_verbose'
44 | #define log_add_verbose(verbose_level, format, args...) log__message(__FILE__, (uint32_t)__LINE__, verbose_level, format, ## args);
| ^~~~
source/core/context.c:66:18: error: 'struct lys_module' has no member named 'imp_size'
66 | if(module->imp_size) {
| ^~
source/core/context.c:68:38: error: 'struct lys_module' has no member named 'imp_size'
68 | for(int i = 0; i < module->imp_size; i++) {
| ^~
In file included from source/core/context.c:21:
source/core/context.c:69:46: error: 'struct lys_module' has no member named 'imp'
69 | log_add(2, "%s(%s), ", module->imp[i].module->name, module->imp[i].module->prefix);
| ^~
source/utils/log_utils.h:45:120: note: in definition of macro 'log_add'
45 | #define log_add(verbose_level, format, args...) log__message(__FILE__, (uint32_t)__LINE__, -verbose_level, format, ## args);
| ^~~~
source/core/context.c:69:75: error: 'struct lys_module' has no member named 'imp'
69 | log_add(2, "%s(%s), ", module->imp[i].module->name, module->imp[i].module->prefix);
| ^~
source/utils/log_utils.h:45:120: note: in definition of macro 'log_add'
45 | #define log_add(verbose_level, format, args...) log__message(__FILE__, (uint32_t)__LINE__, -verbose_level, format, ## args);
|
As documented, these items are now stored in our custom construct sized array, read the docs to get the macro for iterating over them.