From: SangYoun Kwak Date: Tue, 8 Apr 2025 07:14:32 +0000 (+0900) Subject: plugin-api: update-control: Refactor to allocate functions memory in api function... X-Git-Tag: accepted/tizen/unified/20250410.014246^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=898565b0197bc83f0891b8c8ff59c4e30193e14a;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git plugin-api: update-control: Refactor to allocate functions memory in api function for ABI Previously, function structure was created in the backend and the api function used it. But this method depends the function structure to the backend, so it can break the abi rule. To resolve this issue, update-control is refactored to allocate the function structure and give it to the backend to fill the required functions. Change-Id: Icd92dd2dc9342f94bd7d98a3e34519f4fb7b53e8 Signed-off-by: SangYoun Kwak --- diff --git a/src/plugin-api/update-control/src/syscommon-plugin-update-control.c b/src/plugin-api/update-control/src/syscommon-plugin-update-control.c index 6fd20f3..720552d 100644 --- a/src/plugin-api/update-control/src/syscommon-plugin-update-control.c +++ b/src/plugin-api/update-control/src/syscommon-plugin-update-control.c @@ -21,6 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#include + #include #include @@ -36,29 +39,50 @@ static syscommon_plugin_backend_update_control_funcs *funcs = NULL; EXPORT int syscommon_plugin_update_control_get_backend(int *backend_exists) { + int ret = 0; + + if (!backend_exists) { + _E("Invalid parameter: backend_exists is NULL"); + return SYSCOMMON_UPDATE_CONTROL_ERROR_INVALID_PARAMETER; + } + if (funcs) goto get_backend_success; - int ret = syscommon_plugin_common_get_backend( + funcs = calloc(1, sizeof(*funcs)); + if (!funcs) { + _E("Failed to allocate memory for funcs"); + return SYSCOMMON_UPDATE_CONTROL_ERROR_OUT_OF_MEMORY; + } + + ret = syscommon_plugin_common_get_backend( SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL, (void **)&funcs); - if (ret < 0) { - if ((ret == -ENOENT) && backend_exists) { - _I("update-control backend was not found"); - *backend_exists = 0; - return SYSCOMMON_UPDATE_CONTROL_ERROR_NONE; - } + if (ret == -ENOENT) { + _I("update-control backend was not found"); + + free(funcs); + funcs = NULL; + + *backend_exists = 0; + return SYSCOMMON_UPDATE_CONTROL_ERROR_NONE; + } + + if (ret < 0) { _E("Failed to get update-control backend: %d", ret); + + free(funcs); + funcs = NULL; + return SYSCOMMON_UPDATE_CONTROL_ERROR_SYSTEM_ERROR; } _I("Success to get update-control backend: %d", ret); get_backend_success: - if (backend_exists) - *backend_exists = 1; + *backend_exists = 1; return SYSCOMMON_UPDATE_CONTROL_ERROR_NONE; } @@ -76,10 +100,12 @@ int syscommon_plugin_update_control_put_backend(void) _E("Failed to put update-control backend: %d", ret); return SYSCOMMON_UPDATE_CONTROL_ERROR_SYSTEM_ERROR; } - funcs = NULL; _I("Success to put update-control backend: %d", ret); + free(funcs); + funcs = NULL; + return SYSCOMMON_UPDATE_CONTROL_ERROR_NONE; }