From d40a598970b04bfe3a867a5e12debc45c149b46b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 14 Mar 2023 12:19:48 +0000 Subject: plugins: Simplify plugin/codec API versioning Replace the minimum version bound with a check on the size of the API struct. The version only needs to be incremented for ABI breaking changes. Additions to the API won't need to touch the version number, resulting in fewer merge conflicts. Change-Id: I916a04a7bf5890dcf5d615ce30087643165f8e1f --- apps/plugin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps/plugin.c') diff --git a/apps/plugin.c b/apps/plugin.c index cdbe340ddd..1a0aedf3cc 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -864,10 +864,8 @@ int plugin_load(const char* plugin, const void* parameter) } p_hdr = lc_get_header(current_plugin_handle); - hdr = p_hdr ? &p_hdr->lc_hdr : NULL; - if (hdr == NULL || hdr->magic != PLUGIN_MAGIC || hdr->target_id != TARGET_ID @@ -881,13 +879,15 @@ int plugin_load(const char* plugin, const void* parameter) splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_MODEL)); return -1; } - if (hdr->api_version > PLUGIN_API_VERSION - || hdr->api_version < PLUGIN_MIN_API_VERSION) + + if (hdr->api_version != PLUGIN_API_VERSION || + p_hdr->api_size > sizeof(struct plugin_api)) { lc_close(current_plugin_handle); splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_VERSION)); return -1; } + #if (CONFIG_PLATFORM & PLATFORM_NATIVE) /* tlsf crashes observed on arm with 0x4 aligned addresses */ plugin_size = ALIGN_UP(hdr->end_addr - pluginbuf, 0x8); -- cgit v1.2.3