mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Api Symbols: replace asserts with checks (#3507)
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "composite_resolver.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <m-list.h>
|
||||
#include <m-algo.h>
|
||||
|
||||
@@ -25,21 +26,28 @@ static bool composite_api_resolver_callback(
|
||||
return false;
|
||||
}
|
||||
|
||||
CompositeApiResolver* composite_api_resolver_alloc() {
|
||||
CompositeApiResolver* composite_api_resolver_alloc(void) {
|
||||
CompositeApiResolver* resolver = malloc(sizeof(CompositeApiResolver));
|
||||
|
||||
resolver->api_interface.api_version_major = 0;
|
||||
resolver->api_interface.api_version_minor = 0;
|
||||
resolver->api_interface.resolver_callback = &composite_api_resolver_callback;
|
||||
ElfApiInterfaceList_init(resolver->interfaces);
|
||||
|
||||
return resolver;
|
||||
}
|
||||
|
||||
void composite_api_resolver_free(CompositeApiResolver* resolver) {
|
||||
furi_check(resolver);
|
||||
|
||||
ElfApiInterfaceList_clear(resolver->interfaces);
|
||||
free(resolver);
|
||||
}
|
||||
|
||||
void composite_api_resolver_add(CompositeApiResolver* resolver, const ElfApiInterface* interface) {
|
||||
furi_check(resolver);
|
||||
furi_check(interface);
|
||||
|
||||
if(ElfApiInterfaceList_empty_p(resolver->interfaces)) {
|
||||
resolver->api_interface.api_version_major = interface->api_version_major;
|
||||
resolver->api_interface.api_version_minor = interface->api_version_minor;
|
||||
@@ -48,5 +56,6 @@ void composite_api_resolver_add(CompositeApiResolver* resolver, const ElfApiInte
|
||||
}
|
||||
|
||||
const ElfApiInterface* composite_api_resolver_get(CompositeApiResolver* resolver) {
|
||||
furi_check(resolver);
|
||||
return &resolver->api_interface;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef struct CompositeApiResolver CompositeApiResolver;
|
||||
* @brief Allocate composite API resolver
|
||||
* @return CompositeApiResolver* instance
|
||||
*/
|
||||
CompositeApiResolver* composite_api_resolver_alloc();
|
||||
CompositeApiResolver* composite_api_resolver_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free composite API resolver
|
||||
|
||||
@@ -36,6 +36,8 @@ PluginManager* plugin_manager_alloc(
|
||||
}
|
||||
|
||||
void plugin_manager_free(PluginManager* manager) {
|
||||
furi_check(manager);
|
||||
|
||||
for
|
||||
M_EACH(loaded_lib, manager->libs, FlipperApplicationList_t) {
|
||||
flipper_application_free(*loaded_lib);
|
||||
@@ -46,6 +48,7 @@ void plugin_manager_free(PluginManager* manager) {
|
||||
}
|
||||
|
||||
PluginManagerError plugin_manager_load_single(PluginManager* manager, const char* path) {
|
||||
furi_check(manager);
|
||||
FlipperApplication* lib = flipper_application_alloc(manager->storage, manager->api_interface);
|
||||
|
||||
PluginManagerError error = PluginManagerErrorNone;
|
||||
@@ -103,6 +106,7 @@ PluginManagerError plugin_manager_load_single(PluginManager* manager, const char
|
||||
}
|
||||
|
||||
PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* path) {
|
||||
furi_check(manager);
|
||||
File* directory = storage_file_alloc(manager->storage);
|
||||
char file_name_buffer[256];
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
@@ -139,15 +143,21 @@ PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* p
|
||||
}
|
||||
|
||||
uint32_t plugin_manager_get_count(PluginManager* manager) {
|
||||
furi_check(manager);
|
||||
|
||||
return FlipperApplicationList_size(manager->libs);
|
||||
}
|
||||
|
||||
const FlipperAppPluginDescriptor* plugin_manager_get(PluginManager* manager, uint32_t index) {
|
||||
furi_check(manager);
|
||||
|
||||
FlipperApplication* app = *FlipperApplicationList_get(manager->libs, index);
|
||||
return flipper_application_plugin_get_descriptor(app);
|
||||
}
|
||||
|
||||
const void* plugin_manager_get_ep(PluginManager* manager, uint32_t index) {
|
||||
furi_check(manager);
|
||||
|
||||
const FlipperAppPluginDescriptor* lib_descr = plugin_manager_get(manager, index);
|
||||
furi_check(lib_descr);
|
||||
return lib_descr->entry_point;
|
||||
|
||||
Reference in New Issue
Block a user