Skip to content

Commit 613d019

Browse files
committed
MDEV-33160 show_status_array() calls various functions via incompatible pointer
In commit b4ff645 the signature of mysql_show_var_func was changed, but not all functions of that type were adjusted. When the server is configured with `cmake -DWITH_ASAN=ON` and compiled with clang, runtime errors would be flagged for invoking functions through an incompatible function pointer. Reviewed by: Michael 'Monty' Widenius
1 parent 54ed393 commit 613d019

File tree

8 files changed

+102
-104
lines changed

8 files changed

+102
-104
lines changed

sql/mysqld.cc

Lines changed: 69 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7180,25 +7180,25 @@ struct my_option my_long_options[]=
71807180
MYSQL_TO_BE_IMPLEMENTED_OPTION("validate-user-plugins") // NO_EMBEDDED_ACCESS_CHECKS
71817181
};
71827182

7183-
static int show_queries(THD *thd, SHOW_VAR *var, char *buff,
7184-
enum enum_var_type scope)
7183+
static int show_queries(THD *thd, SHOW_VAR *var, void *,
7184+
system_status_var *, enum_var_type)
71857185
{
71867186
var->type= SHOW_LONGLONG;
71877187
var->value= &thd->query_id;
71887188
return 0;
71897189
}
71907190

71917191

7192-
static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff,
7193-
enum enum_var_type scope)
7192+
static int show_net_compression(THD *thd, SHOW_VAR *var, void *,
7193+
system_status_var *, enum_var_type)
71947194
{
71957195
var->type= SHOW_MY_BOOL;
71967196
var->value= &thd->net.compress;
71977197
return 0;
71987198
}
71997199

7200-
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff,
7201-
enum enum_var_type scope)
7200+
static int show_starttime(THD *thd, SHOW_VAR *var, void *buff,
7201+
system_status_var *, enum_var_type)
72027202
{
72037203
var->type= SHOW_LONG;
72047204
var->value= buff;
@@ -7207,8 +7207,8 @@ static int show_starttime(THD *thd, SHOW_VAR *var, char *buff,
72077207
}
72087208

72097209
#ifdef ENABLED_PROFILING
7210-
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff,
7211-
enum enum_var_type scope)
7210+
static int show_flushstatustime(THD *thd, SHOW_VAR *var, void *buff,
7211+
system_status_var *, enum_var_type)
72127212
{
72137213
var->type= SHOW_LONG;
72147214
var->value= buff;
@@ -7218,32 +7218,28 @@ static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff,
72187218
#endif
72197219

72207220
#ifdef HAVE_REPLICATION
7221-
static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff,
7222-
enum enum_var_type scope)
7221+
static int show_rpl_status(THD *, SHOW_VAR *var, void *, system_status_var *,
7222+
enum_var_type)
72237223
{
72247224
var->type= SHOW_CHAR;
72257225
var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]);
72267226
return 0;
72277227
}
72287228

7229-
static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff,
7230-
enum enum_var_type scope)
7229+
static int show_slave_running(THD *thd, SHOW_VAR *var, void *buff,
7230+
system_status_var *, enum_var_type)
72317231
{
7232-
Master_info *mi= NULL;
7233-
bool UNINIT_VAR(tmp);
7234-
7235-
var->type= SHOW_MY_BOOL;
7236-
var->value= buff;
7237-
7238-
if ((mi= get_master_info(&thd->variables.default_master_connection,
7239-
Sql_condition::WARN_LEVEL_NOTE)))
7232+
if (Master_info *mi=
7233+
get_master_info(&thd->variables.default_master_connection,
7234+
Sql_condition::WARN_LEVEL_NOTE))
72407235
{
7241-
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_READING &&
7242-
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN);
7236+
*((my_bool*) buff)=
7237+
(mi->slave_running == MYSQL_SLAVE_RUN_READING &&
7238+
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN);
72437239
mi->release();
7240+
var->type= SHOW_MY_BOOL;
7241+
var->value= buff;
72447242
}
7245-
if (mi)
7246-
*((my_bool *)buff)= tmp;
72477243
else
72487244
var->type= SHOW_UNDEF;
72497245
return 0;
@@ -7253,7 +7249,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff,
72537249
/* How many masters this slave is connected to */
72547250

72557251

7256-
static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff)
7252+
static int show_slaves_running(THD *, SHOW_VAR *var, void *buff,
7253+
system_status_var *, enum_var_type)
72577254
{
72587255
var->type= SHOW_LONGLONG;
72597256
var->value= buff;
@@ -7264,39 +7261,35 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff)
72647261
}
72657262

72667263

7267-
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff,
7268-
enum enum_var_type scope)
7264+
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, void *buff,
7265+
system_status_var *, enum_var_type)
72697266
{
7270-
Master_info *mi;
7271-
7272-
var->type= SHOW_LONGLONG;
7273-
var->value= buff;
7274-
7275-
if ((mi= get_master_info(&thd->variables.default_master_connection,
7276-
Sql_condition::WARN_LEVEL_NOTE)))
7267+
if (Master_info *mi=
7268+
get_master_info(&thd->variables.default_master_connection,
7269+
Sql_condition::WARN_LEVEL_NOTE))
72777270
{
72787271
*((longlong *)buff)= mi->received_heartbeats;
72797272
mi->release();
7273+
var->type= SHOW_LONGLONG;
7274+
var->value= buff;
72807275
}
72817276
else
72827277
var->type= SHOW_UNDEF;
72837278
return 0;
72847279
}
72857280

72867281

7287-
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff,
7288-
enum enum_var_type scope)
7282+
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, void *buff,
7283+
system_status_var *, enum_var_type)
72897284
{
7290-
Master_info *mi;
7291-
7292-
var->type= SHOW_CHAR;
7293-
var->value= buff;
7294-
7295-
if ((mi= get_master_info(&thd->variables.default_master_connection,
7296-
Sql_condition::WARN_LEVEL_NOTE)))
7285+
if (Master_info *mi=
7286+
get_master_info(&thd->variables.default_master_connection,
7287+
Sql_condition::WARN_LEVEL_NOTE))
72977288
{
7298-
sprintf(buff, "%.3f", mi->heartbeat_period);
7289+
sprintf(static_cast<char*>(buff), "%.3f", mi->heartbeat_period);
72997290
mi->release();
7291+
var->type= SHOW_CHAR;
7292+
var->value= buff;
73007293
}
73017294
else
73027295
var->type= SHOW_UNDEF;
@@ -7306,17 +7299,17 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff,
73067299

73077300
#endif /* HAVE_REPLICATION */
73087301

7309-
static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff,
7310-
enum enum_var_type scope)
7302+
static int show_open_tables(THD *, SHOW_VAR *var, void *buff,
7303+
system_status_var *, enum_var_type)
73117304
{
73127305
var->type= SHOW_LONG;
73137306
var->value= buff;
73147307
*((long *) buff)= (long) tc_records();
73157308
return 0;
73167309
}
73177310

7318-
static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff,
7319-
enum enum_var_type scope)
7311+
static int show_prepared_stmt_count(THD *, SHOW_VAR *var, void *buff,
7312+
system_status_var *, enum_var_type)
73207313
{
73217314
var->type= SHOW_LONG;
73227315
var->value= buff;
@@ -7326,8 +7319,8 @@ static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff,
73267319
return 0;
73277320
}
73287321

7329-
static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
7330-
enum enum_var_type scope)
7322+
static int show_table_definitions(THD *, SHOW_VAR *var, void *buff,
7323+
system_status_var *, enum_var_type)
73317324
{
73327325
var->type= SHOW_LONG;
73337326
var->value= buff;
@@ -7336,8 +7329,8 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
73367329
}
73377330

73387331

7339-
static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
7340-
enum enum_var_type scope)
7332+
static int show_flush_commands(THD *, SHOW_VAR *var, void *buff,
7333+
system_status_var *, enum_var_type)
73417334
{
73427335
var->type= SHOW_LONGLONG;
73437336
var->value= buff;
@@ -7356,8 +7349,8 @@ static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
73567349
inside an Event.
73577350
*/
73587351

7359-
static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff,
7360-
enum enum_var_type scope)
7352+
static int show_ssl_get_version(THD *thd, SHOW_VAR *var, void *,
7353+
system_status_var *, enum_var_type)
73617354
{
73627355
var->type= SHOW_CHAR;
73637356
if( thd->vio_ok() && thd->net.vio->ssl_arg )
@@ -7367,8 +7360,8 @@ static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff,
73677360
return 0;
73687361
}
73697362

7370-
static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff,
7371-
enum enum_var_type scope)
7363+
static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, void *buff,
7364+
system_status_var *, enum_var_type)
73727365
{
73737366
var->type= SHOW_LONG;
73747367
var->value= buff;
@@ -7379,8 +7372,8 @@ static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff,
73797372
return 0;
73807373
}
73817374

7382-
static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
7383-
enum enum_var_type scope)
7375+
static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, void *buff,
7376+
system_status_var *, enum_var_type)
73847377
{
73857378
var->type= SHOW_LONG;
73867379
var->value= buff;
@@ -7395,8 +7388,8 @@ static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
73957388
return 0;
73967389
}
73977390

7398-
static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
7399-
enum enum_var_type scope)
7391+
static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, void *buff,
7392+
system_status_var *, enum_var_type)
74007393
{
74017394
var->type= SHOW_LONG;
74027395
var->value= buff;
@@ -7408,8 +7401,8 @@ static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
74087401
return 0;
74097402
}
74107403

7411-
static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff,
7412-
enum enum_var_type scope)
7404+
static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, void *buff,
7405+
system_status_var *, enum_var_type)
74137406
{
74147407
var->type= SHOW_CHAR;
74157408
if( thd->vio_ok() && thd->net.vio->ssl_arg )
@@ -7419,9 +7412,10 @@ static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff,
74197412
return 0;
74207413
}
74217414

7422-
static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff,
7423-
enum enum_var_type scope)
7415+
static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, void *buf,
7416+
system_status_var *, enum_var_type)
74247417
{
7418+
char *buff= static_cast<char*>(buf);
74257419
var->type= SHOW_CHAR;
74267420
var->value= buff;
74277421
if (thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7506,8 +7500,8 @@ my_asn1_time_to_string(const ASN1_TIME *time, char *buf, size_t len)
75067500
*/
75077501

75087502
static int
7509-
show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
7510-
enum enum_var_type scope)
7503+
show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, void *buff,
7504+
system_status_var *, enum_var_type)
75117505
{
75127506
var->type= SHOW_CHAR;
75137507
if(thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7516,7 +7510,7 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
75167510
X509 *cert= SSL_get_certificate(ssl);
75177511
const ASN1_TIME *not_before= X509_get0_notBefore(cert);
75187512

7519-
var->value= my_asn1_time_to_string(not_before, buff,
7513+
var->value= my_asn1_time_to_string(not_before, static_cast<char*>(buff),
75207514
SHOW_VAR_FUNC_BUFF_SIZE);
75217515
if (!var->value)
75227516
return 1;
@@ -7540,8 +7534,8 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
75407534
*/
75417535

75427536
static int
7543-
show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
7544-
enum enum_var_type scope)
7537+
show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, void *buff,
7538+
system_status_var *, enum_var_type)
75457539
{
75467540
var->type= SHOW_CHAR;
75477541
if(thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7550,7 +7544,7 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
75507544
X509 *cert= SSL_get_certificate(ssl);
75517545
const ASN1_TIME *not_after= X509_get0_notAfter(cert);
75527546

7553-
var->value= my_asn1_time_to_string(not_after, buff,
7547+
var->value= my_asn1_time_to_string(not_after, static_cast<char*>(buff),
75547548
SHOW_VAR_FUNC_BUFF_SIZE);
75557549
if (!var->value)
75567550
return 1;
@@ -7604,7 +7598,7 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, void *buff,
76047598
}
76057599

76067600

7607-
static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff,
7601+
static int show_memory_used(THD *thd, SHOW_VAR *var, void *buff,
76087602
struct system_status_var *status_var,
76097603
enum enum_var_type scope)
76107604
{
@@ -7660,8 +7654,8 @@ static int debug_status_func(THD *thd, SHOW_VAR *var, void *buff,
76607654
#endif
76617655

76627656
#ifdef HAVE_POOL_OF_THREADS
7663-
int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
7664-
enum enum_var_type scope)
7657+
int show_threadpool_idle_threads(THD *, SHOW_VAR *var, void *buff,
7658+
system_status_var *, enum_var_type)
76657659
{
76667660
var->type= SHOW_INT;
76677661
var->value= buff;
@@ -7670,8 +7664,8 @@ int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
76707664
}
76717665

76727666

7673-
static int show_threadpool_threads(THD *thd, SHOW_VAR *var, char *buff,
7674-
enum enum_var_type scope)
7667+
static int show_threadpool_threads(THD *, SHOW_VAR *var, void *buff,
7668+
system_status_var *, enum_var_type)
76757669
{
76767670
var->type= SHOW_INT;
76777671
var->value= buff;

sql/sql_acl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11869,8 +11869,8 @@ static my_bool count_column_grants(void *grant_table,
1186911869
This must be performed under the mutex in order to make sure the
1187011870
iteration does not fail.
1187111871
*/
11872-
static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff,
11873-
enum enum_var_type scope)
11872+
static int show_column_grants(THD *thd, SHOW_VAR *var, void *buff,
11873+
system_status_var *, enum enum_var_type scope)
1187411874
{
1187511875
var->type= SHOW_ULONG;
1187611876
var->value= buff;
@@ -11886,8 +11886,8 @@ static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff,
1188611886
return 0;
1188711887
}
1188811888

11889-
static int show_database_grants(THD *thd, SHOW_VAR *var, char *buff,
11890-
enum enum_var_type scope)
11889+
static int show_database_grants(THD *thd, SHOW_VAR *var, void *buff,
11890+
system_status_var *, enum enum_var_type scope)
1189111891
{
1189211892
var->type= SHOW_UINT;
1189311893
var->value= buff;

sql/table_cache.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,8 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
13451345
}
13461346

13471347

1348-
int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff,
1349-
enum enum_var_type scope)
1348+
int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff,
1349+
system_status_var *, enum enum_var_type scope)
13501350
{
13511351
var->type= SHOW_UINT;
13521352
var->value= buff;

sql/table_cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
9797
bool no_dups= false);
9898

9999
extern uint tc_records(void);
100-
int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff,
101-
enum enum_var_type scope);
100+
int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff,
101+
system_status_var *, enum enum_var_type scope);
102102
extern void tc_purge(bool mark_flushed= false);
103103
extern void tc_add_table(THD *thd, TABLE *table);
104104
extern void tc_release_table(TABLE *table);

sql/threadpool.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ extern int tp_get_thread_count();
6464
/* Activate threadpool scheduler */
6565
extern void tp_scheduler(void);
6666

67-
extern int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
68-
enum enum_var_type scope);
69-
7067
enum TP_PRIORITY {
7168
TP_PRIORITY_HIGH,
7269
TP_PRIORITY_LOW,

0 commit comments

Comments
 (0)