add TK_FUNC_NAME_LEN

This commit is contained in:
lixianjing 2020-12-02 14:17:54 +08:00
parent dd6092d404
commit 2b9bb92aa5
2 changed files with 8 additions and 5 deletions

View File

@ -50,7 +50,7 @@ static ret_t plugin_destroy(plugin_t* plugin) {
if (plugin->plugin_manager != NULL && plugin->handle != NULL) {
char name[MAX_PATH + 1];
char func[TK_NAME_LEN + 1];
char func[TK_FUNC_NAME_LEN + 1];
tk_dl_t* handle = plugin->handle;
const char* lib_name = plugin->lib_name;
plugin_manager_t* plugin_manager = plugin->plugin_manager;
@ -61,7 +61,7 @@ static ret_t plugin_destroy(plugin_t* plugin) {
plugin_manager->get_deinit(func, name_from_lib_name(name, lib_name)) == RET_OK) {
log_debug("deinit func:%s\n", func);
} else {
tk_strncpy(func, TK_PLUGIN_DEINIT, TK_NAME_LEN);
tk_strncpy(func, TK_PLUGIN_DEINIT, TK_FUNC_NAME_LEN);
}
plugin_deinit_func_t deinit = (plugin_deinit_func_t)tk_dl_sym(handle, func);
if (deinit != NULL) {
@ -110,7 +110,7 @@ static plugin_t* plugin_create(const char* path, const char* lib_name,
if (plugin != NULL) {
char name[MAX_PATH + 1];
char func[TK_NAME_LEN + 1];
char func[TK_FUNC_NAME_LEN + 1];
memset(name, 0x00, sizeof(name));
memset(func, 0x00, sizeof(func));
@ -118,7 +118,7 @@ static plugin_t* plugin_create(const char* path, const char* lib_name,
plugin_manager->get_init(func, name_from_lib_name(name, lib_name)) == RET_OK) {
log_debug("init func:%s\n", func);
} else {
tk_strncpy(func, TK_PLUGIN_INIT, TK_NAME_LEN);
tk_strncpy(func, TK_PLUGIN_INIT, TK_FUNC_NAME_LEN);
}
plugin_init_func_t init = (plugin_init_func_t)tk_dl_sym(handle, func);
if (init != NULL) {

View File

@ -330,7 +330,10 @@ typedef ret_t (*tk_visit_t)(void* ctx, const void* data);
typedef ret_t (*tk_callback_t)(void* ctx);
/*TK_NAME_LEN+1 must aligned to 4*/
enum { TK_NAME_LEN = 31 };
enum {
TK_NAME_LEN = 31,
TK_FUNC_NAME_LEN = 63
};
#ifdef WITH_CPPCHECK
#define tk_str_eq strcmp