From 6567fceaec94f90df094c1e2519c050ac444df27 Mon Sep 17 00:00:00 2001 From: anth64 Date: Thu, 29 Jan 2026 22:53:11 +0100 Subject: [PATCH] chore: formalize module loading error codes * Define Constants: Added STK_MOD_LIBRARY_LOAD_ERROR and STK_MOD_SYMBOL_NOT_FOUND_ERROR to the public header. * Update module.c: Swapped out the -1 and -2 placeholders for the new named constants in stk_module_load. --- include/stk.h | 2 ++ src/module.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/stk.h b/include/stk.h index 58af9a8..27c1e3b 100644 --- a/include/stk.h +++ b/include/stk.h @@ -13,6 +13,8 @@ /* Modules */ #define STK_MOD_INIT_SUCCESS 0 #define STK_MOD_INIT_FAILURE 1 +#define STK_MOD_LIBRARY_LOAD_ERROR 2 +#define STK_MOD_SYMBOL_NOT_FOUND_ERROR 3 #if defined(__linux__) || defined(_WIN32) #define STK_EVENT_BUFFER 4096 diff --git a/src/module.c b/src/module.c index 79a50ab..49922f9 100644 --- a/src/module.c +++ b/src/module.c @@ -91,7 +91,7 @@ int stk_module_load(const char *path, int index) handle = platform_load_library(path); if (!handle) - return -1; + return STK_MOD_LIBRARY_LOAD_ERROR; u.obj = platform_get_symbol(handle, stk_mod_init_name); init_func = u.init_func; @@ -101,7 +101,7 @@ int stk_module_load(const char *path, int index) if (!init_func || !shutdown_func) { platform_unload_library(handle); - return -2; + return STK_MOD_SYMBOL_NOT_FOUND_ERROR; } extract_module_id(path, module_id);