MDEV-33158: UBSAN - plugin.cc partial move to C++ casts
There were too many C casts rather than C++ casts here. Started a partial conversion covering within-file scoped changes. Suggested by Brandon Nesterenko
This commit is contained in:
parent
d7f27d7172
commit
c3fd0f189a
@ -3186,14 +3186,14 @@ void sync_dynamic_session_variables(THD* thd, bool global_lock)
|
|||||||
If required, will sync with global variables if the requested variable
|
If required, will sync with global variables if the requested variable
|
||||||
has not yet been allocated in the current thread.
|
has not yet been allocated in the current thread.
|
||||||
*/
|
*/
|
||||||
static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
|
static void *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("intern_sys_var_ptr");
|
DBUG_ENTER("intern_sys_var_ptr");
|
||||||
DBUG_ASSERT(offset >= 0);
|
DBUG_ASSERT(offset >= 0);
|
||||||
DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head);
|
DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head);
|
||||||
|
|
||||||
if (!thd)
|
if (!thd)
|
||||||
DBUG_RETURN((uchar*) global_system_variables.dynamic_variables_ptr + offset);
|
DBUG_RETURN(global_system_variables.dynamic_variables_ptr + offset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
dynamic_variables_head points to the largest valid offset
|
dynamic_variables_head points to the largest valid offset
|
||||||
@ -3205,7 +3205,7 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
|
|||||||
sync_dynamic_session_variables(thd, global_lock);
|
sync_dynamic_session_variables(thd, global_lock);
|
||||||
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
||||||
}
|
}
|
||||||
DBUG_RETURN((uchar*)thd->variables.dynamic_variables_ptr + offset);
|
DBUG_RETURN(thd->variables.dynamic_variables_ptr + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3219,47 +3219,47 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
|
|||||||
|
|
||||||
static char *mysql_sys_var_char(THD* thd, int offset)
|
static char *mysql_sys_var_char(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (char *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<char*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int *mysql_sys_var_int(THD* thd, int offset)
|
static int *mysql_sys_var_int(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (int *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<int*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int *mysql_sys_var_uint(THD* thd, int offset)
|
static unsigned int *mysql_sys_var_uint(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (unsigned int *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<unsigned int*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static long *mysql_sys_var_long(THD* thd, int offset)
|
static long *mysql_sys_var_long(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (long *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<long*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long *mysql_sys_var_ulong(THD* thd, int offset)
|
static unsigned long *mysql_sys_var_ulong(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (unsigned long *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<unsigned long*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static long long *mysql_sys_var_longlong(THD* thd, int offset)
|
static long long *mysql_sys_var_longlong(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (long long *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<long long*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long long *mysql_sys_var_ulonglong(THD* thd, int offset)
|
static unsigned long long *mysql_sys_var_ulonglong(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (unsigned long long *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<unsigned long long*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **mysql_sys_var_str(THD* thd, int offset)
|
static char **mysql_sys_var_str(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (char **) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<char**>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static double *mysql_sys_var_double(THD* thd, int offset)
|
static double *mysql_sys_var_double(THD* thd, int offset)
|
||||||
{
|
{
|
||||||
return (double *) intern_sys_var_ptr(thd, offset, true);
|
return static_cast<double*>(intern_sys_var_ptr(thd, offset, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_thdvar_init(THD *thd)
|
void plugin_thdvar_init(THD *thd)
|
||||||
@ -3520,7 +3520,7 @@ uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) const
|
|||||||
if (type == OPT_GLOBAL)
|
if (type == OPT_GLOBAL)
|
||||||
thd= NULL;
|
thd= NULL;
|
||||||
|
|
||||||
return intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false);
|
return (uchar*) intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false);
|
||||||
}
|
}
|
||||||
return *(uchar**) (plugin_var+1);
|
return *(uchar**) (plugin_var+1);
|
||||||
}
|
}
|
||||||
@ -3529,8 +3529,8 @@ uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) const
|
|||||||
bool sys_var_pluginvar::session_is_default(THD *thd)
|
bool sys_var_pluginvar::session_is_default(THD *thd)
|
||||||
{
|
{
|
||||||
uchar *value= plugin_var->flags & PLUGIN_VAR_THDLOCAL
|
uchar *value= plugin_var->flags & PLUGIN_VAR_THDLOCAL
|
||||||
? intern_sys_var_ptr(thd, *(int*) (plugin_var+1), true)
|
? static_cast<uchar*>(intern_sys_var_ptr(thd, *(int*) (plugin_var+1), true))
|
||||||
: *(uchar**) (plugin_var+1);
|
: *reinterpret_cast<uchar**>(plugin_var+1);
|
||||||
|
|
||||||
real_value_ptr(thd, OPT_SESSION);
|
real_value_ptr(thd, OPT_SESSION);
|
||||||
|
|
||||||
@ -3772,27 +3772,27 @@ void plugin_opt_set_limits(struct my_option *options,
|
|||||||
break;
|
break;
|
||||||
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
||||||
options->var_type= GET_ENUM;
|
options->var_type= GET_ENUM;
|
||||||
options->typelib= ((thdvar_enum_t*) opt)->typelib;
|
options->typelib= reinterpret_cast<const thdvar_enum_t*>(opt)->typelib;
|
||||||
options->def_value= ((thdvar_enum_t*) opt)->def_val;
|
options->def_value= reinterpret_cast<const thdvar_enum_t*>(opt)->def_val;
|
||||||
options->min_value= options->block_size= 0;
|
options->min_value= options->block_size= 0;
|
||||||
options->max_value= options->typelib->count - 1;
|
options->max_value= options->typelib->count - 1;
|
||||||
break;
|
break;
|
||||||
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
||||||
options->var_type= GET_SET;
|
options->var_type= GET_SET;
|
||||||
options->typelib= ((thdvar_set_t*) opt)->typelib;
|
options->typelib= reinterpret_cast<const thdvar_set_t*>(opt)->typelib;
|
||||||
options->def_value= ((thdvar_set_t*) opt)->def_val;
|
options->def_value= reinterpret_cast<const thdvar_set_t*>(opt)->def_val;
|
||||||
options->min_value= options->block_size= 0;
|
options->min_value= options->block_size= 0;
|
||||||
options->max_value= (1ULL << options->typelib->count) - 1;
|
options->max_value= (1ULL << options->typelib->count) - 1;
|
||||||
break;
|
break;
|
||||||
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
|
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
|
||||||
options->var_type= GET_BOOL;
|
options->var_type= GET_BOOL;
|
||||||
options->def_value= ((thdvar_bool_t*) opt)->def_val;
|
options->def_value= reinterpret_cast<const thdvar_bool_t*>(opt)->def_val;
|
||||||
options->typelib= &bool_typelib;
|
options->typelib= &bool_typelib;
|
||||||
break;
|
break;
|
||||||
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
|
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
|
||||||
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?
|
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?
|
||||||
GET_STR_ALLOC : GET_STR);
|
GET_STR_ALLOC : GET_STR);
|
||||||
options->def_value= (intptr) ((thdvar_str_t*) opt)->def_val;
|
options->def_value= reinterpret_cast<intptr_t>(reinterpret_cast<const thdvar_str_t*>(opt)->def_val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBUG_ASSERT(0);
|
DBUG_ASSERT(0);
|
||||||
@ -3831,7 +3831,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
|
|||||||
size_t plugin_name_len= strlen(plugin_name);
|
size_t plugin_name_len= strlen(plugin_name);
|
||||||
size_t optnamelen;
|
size_t optnamelen;
|
||||||
const int max_comment_len= 255;
|
const int max_comment_len= 255;
|
||||||
char *comment= (char *) alloc_root(mem_root, max_comment_len + 1);
|
char *comment= static_cast<char*>(alloc_root(mem_root, max_comment_len + 1));
|
||||||
char *optname;
|
char *optname;
|
||||||
|
|
||||||
int index= 0, UNINIT_VAR(offset);
|
int index= 0, UNINIT_VAR(offset);
|
||||||
@ -3843,7 +3843,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
|
|||||||
|
|
||||||
DBUG_ENTER("construct_options");
|
DBUG_ENTER("construct_options");
|
||||||
|
|
||||||
plugin_name_ptr= (char*) alloc_root(mem_root, plugin_name_len + 1);
|
plugin_name_ptr= static_cast<char*>(alloc_root(mem_root, plugin_name_len + 1));
|
||||||
safe_strcpy(plugin_name_ptr, plugin_name_len + 1, plugin_name);
|
safe_strcpy(plugin_name_ptr, plugin_name_len + 1, plugin_name);
|
||||||
my_casedn_str(&my_charset_latin1, plugin_name_ptr);
|
my_casedn_str(&my_charset_latin1, plugin_name_ptr);
|
||||||
convert_underscore_to_dash(plugin_name_ptr, plugin_name_len);
|
convert_underscore_to_dash(plugin_name_ptr, plugin_name_len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user