MDEV-34348: Fix casting related to plugins

Partial commit of the greater MDEV-34348 scope.
MDEV-34348: MariaDB is violating clang-16 -Wcast-function-type-strict

Reviewed By:
============
Marko Mäkelä <marko.makela@mariadb.com>
This commit is contained in:
Brandon Nesterenko 2024-10-26 13:53:51 -06:00
parent 840fe316d4
commit 7a8eb26bda
9 changed files with 39 additions and 27 deletions

View file

@ -194,7 +194,7 @@ const char *encryption_plugin_get_config()
return encryption_plugin_config.c_str();
}
extern int finalize_encryption_plugin(st_plugin_int *plugin);
extern int finalize_encryption_plugin(void *plugin);
void encryption_plugin_prepare_init(int argc, char **argv)

View file

@ -59,8 +59,9 @@ uint ctx_size(unsigned int, unsigned int)
} /* extern "C" */
int initialize_encryption_plugin(st_plugin_int *plugin)
int initialize_encryption_plugin(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
if (encryption_manager)
return 1;
@ -107,8 +108,9 @@ int initialize_encryption_plugin(st_plugin_int *plugin)
return 0;
}
int finalize_encryption_plugin(st_plugin_int *plugin)
int finalize_encryption_plugin(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
bool used= plugin_ref_to_int(encryption_manager) == plugin;
if (used)

View file

@ -566,8 +566,9 @@ static int hton_drop_table(handlerton *hton, const char *path)
}
int ha_finalize_handlerton(st_plugin_int *plugin)
int ha_finalize_handlerton(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
handlerton *hton= (handlerton *)plugin->data;
DBUG_ENTER("ha_finalize_handlerton");
@ -618,8 +619,9 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
}
int ha_initialize_handlerton(st_plugin_int *plugin)
int ha_initialize_handlerton(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
handlerton *hton;
static const char *no_exts[]= { 0 };
int ret= 0;

View file

@ -5101,8 +5101,8 @@ static inline bool ha_storage_engine_is_enabled(const handlerton *db_type)
int ha_init_errors(void);
int ha_init(void);
int ha_end(void);
int ha_initialize_handlerton(st_plugin_int *plugin);
int ha_finalize_handlerton(st_plugin_int *plugin);
int ha_initialize_handlerton(void *plugin);
int ha_finalize_handlerton(void *plugin);
TYPELIB *ha_known_exts(void);
int ha_panic(enum ha_panic_function flag);

View file

@ -18,8 +18,8 @@
#include "mysqld.h"
#include "sql_audit.h"
extern int initialize_audit_plugin(st_plugin_int *plugin);
extern int finalize_audit_plugin(st_plugin_int *plugin);
extern int initialize_audit_plugin(void *plugin);
extern int finalize_audit_plugin(void *plugin);
#ifndef EMBEDDED_LIBRARY
@ -262,8 +262,9 @@ void mysql_audit_finalize()
@retval TRUE There was an error.
*/
int initialize_audit_plugin(st_plugin_int *plugin)
int initialize_audit_plugin(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
st_mysql_audit *data= (st_mysql_audit*) plugin->plugin->info;
if (!data->event_notify || !data->class_mask[0])
@ -346,8 +347,9 @@ static my_bool calc_class_mask(THD *thd, plugin_ref plugin, void *arg)
@retval FALSE OK
@retval TRUE There was an error.
*/
int finalize_audit_plugin(st_plugin_int *plugin)
int finalize_audit_plugin(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
if (plugin->plugin->deinit && plugin->plugin->deinit(NULL))
@ -458,13 +460,13 @@ void mysql_audit_finalize()
}
int initialize_audit_plugin(st_plugin_int *plugin)
int initialize_audit_plugin(void *plugin)
{
return 1;
}
int finalize_audit_plugin(st_plugin_int *plugin)
int finalize_audit_plugin(void *plugin)
{
return 0;
}

View file

@ -103,16 +103,16 @@ const LEX_CSTRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{ STRING_WITH_LEN("FUNCTION") }
};
extern int initialize_schema_table(st_plugin_int *plugin);
extern int finalize_schema_table(st_plugin_int *plugin);
extern int initialize_schema_table(void *plugin);
extern int finalize_schema_table(void *plugin);
extern int initialize_audit_plugin(st_plugin_int *plugin);
extern int finalize_audit_plugin(st_plugin_int *plugin);
extern int initialize_audit_plugin(void *plugin);
extern int finalize_audit_plugin(void *plugin);
extern int initialize_encryption_plugin(st_plugin_int *plugin);
extern int finalize_encryption_plugin(st_plugin_int *plugin);
extern int initialize_encryption_plugin(void *plugin);
extern int finalize_encryption_plugin(void *plugin);
extern int initialize_data_type_plugin(st_plugin_int *plugin);
extern int initialize_data_type_plugin(void *plugin);
/*
The number of elements in both plugin_type_initialize and
@ -1446,8 +1446,9 @@ static int plugin_do_initialize(struct st_plugin_int *plugin, uint &state)
mysql_mutex_assert_not_owner(&LOCK_plugin);
plugin_type_init init= plugin_type_initialize[plugin->plugin->type];
if (!init)
init= (plugin_type_init) plugin->plugin->init;
init= plugin->plugin->init;
if (init)
{
if (int ret= init(plugin))
{
/* Plugin init failed and did not requested a retry */
@ -1455,6 +1456,7 @@ static int plugin_do_initialize(struct st_plugin_int *plugin, uint &state)
print_init_failed_error(plugin);
DBUG_RETURN(ret);
}
}
state= PLUGIN_IS_READY; // plugin->init() succeeded
if (plugin->plugin->status_vars)

View file

@ -152,7 +152,7 @@ typedef struct st_plugin_int **plugin_ref;
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
#endif
typedef int (*plugin_type_init)(struct st_plugin_int *);
typedef int (*plugin_type_init)(void *);
extern I_List<i_string> *opt_plugin_load_list_ptr;
extern char *opt_plugin_dir_ptr;

View file

@ -9938,8 +9938,9 @@ ST_SCHEMA_TABLE schema_tables[]=
};
int initialize_schema_table(st_plugin_int *plugin)
int initialize_schema_table(void *plugin_)
{
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
ST_SCHEMA_TABLE *schema_table;
int err;
DBUG_ENTER("initialize_schema_table");
@ -9984,9 +9985,10 @@ int initialize_schema_table(st_plugin_int *plugin)
DBUG_RETURN(0);
}
int finalize_schema_table(st_plugin_int *plugin)
int finalize_schema_table(void *plugin_)
{
ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
ST_SCHEMA_TABLE *schema_table= static_cast<ST_SCHEMA_TABLE *>(plugin->data);
DBUG_ENTER("finalize_schema_table");
if (schema_table)

View file

@ -9566,9 +9566,11 @@ Charset::eq_collation_specific_names(CHARSET_INFO *cs) const
return name0.length && !cmp(&name0, &name1);
}
int initialize_data_type_plugin(st_plugin_int *plugin)
int initialize_data_type_plugin(void *plugin_)
{
st_mariadb_data_type *data= (st_mariadb_data_type*) plugin->plugin->info;
st_plugin_int *plugin= static_cast<st_plugin_int *>(plugin_);
st_mariadb_data_type *data=
static_cast<st_mariadb_data_type *>(plugin->plugin->info);
data->type_handler->set_name(Name(plugin->name));
if (plugin->plugin->init && plugin->plugin->init(NULL))
{