From f0c657d1697aa6404f2c7e392889d80bd0c25a12 Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Tue, 8 Apr 2025 16:25:13 +0900 Subject: [PATCH] Refactor to fill plugin function structure rather than just give structure To support ABI compatibility, the plugin api allocates the plugin function structure and gives its pointer to backend. According to this change, update-control-generic backend fills required functions rather than just hand over the plugin function structure. Change-Id: I6077e0abda1542fbc24de83e0ea29dbdc3fe4651 Signed-off-by: SangYoun Kwak --- src/plugin.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/plugin.c b/src/plugin.c index 904eca3..679f365 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -665,20 +665,29 @@ static int update_control_get_property(syscommon_update_control_property_e prope return ret; } -static syscommon_plugin_backend_update_control_funcs plugin_funcs = { - .update_control_initialize = update_control_initialize, - .update_control_deinitialize = update_control_deinitialize, - .update_control_check_new_version = update_control_check_new_version, - .update_control_download_package = update_control_download_package, - .update_control_do_update = update_control_do_update, - .update_control_make_reservation = update_control_make_reservation, - .update_control_cancel_reservation = update_control_cancel_reservation, - .update_control_get_property = update_control_get_property, -}; - static int update_control_init(void **data) { - *data = (void *)&plugin_funcs; + syscommon_plugin_backend_update_control_funcs *plugin_funcs = NULL; + + if (!data) { + _E("Invalid parameter: data is NULL"); + return -EINVAL; + } + + plugin_funcs = *((syscommon_plugin_backend_update_control_funcs **)data); + if (!plugin_funcs) { + _E("Invalid parameter: plugin_funcs is NULL"); + return -EINVAL; + } + + plugin_funcs->update_control_initialize = update_control_initialize; + plugin_funcs->update_control_deinitialize = update_control_deinitialize; + plugin_funcs->update_control_check_new_version = update_control_check_new_version; + plugin_funcs->update_control_download_package = update_control_download_package; + plugin_funcs->update_control_do_update = update_control_do_update; + plugin_funcs->update_control_make_reservation = update_control_make_reservation; + plugin_funcs->update_control_cancel_reservation = update_control_cancel_reservation; + plugin_funcs->update_control_get_property = update_control_get_property; return 0; } -- 2.34.1