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
This commit is contained in:
Aidan MacDonald 2023-03-14 12:19:48 +00:00
parent 2fb2364686
commit d40a598970
7 changed files with 49 additions and 37 deletions

View file

@ -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);