Skip to content

Commit b68c2bd

Browse files
committed
Bug#28787273: FIX -WCAST-QUAL COMPILATION WARNINGS [noclose]
Avoid casting away constness using C-style cast. Either use const consistently or explicitly remove const with const_cast. Patch 8. Change-Id: I3310e085337928806ac8e6c96b35672aa3d2c03d
1 parent 9060575 commit b68c2bd

28 files changed

+152
-128
lines changed

components/mysql_server/log_builtins.cc

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -310,31 +310,31 @@ typedef struct _log_item_wellknown_key {
310310
error code. Et cetera!
311311
*/
312312
static const log_item_wellknown_key log_item_wellknown_keys[] = {
313-
{C_STRING_WITH_LEN("--ERROR--"), LOG_UNTYPED, LOG_ITEM_END},
314-
{C_STRING_WITH_LEN("log_type"), LOG_INTEGER, LOG_ITEM_LOG_TYPE},
315-
{C_STRING_WITH_LEN("err_code"), LOG_INTEGER, LOG_ITEM_SQL_ERRCODE},
316-
{C_STRING_WITH_LEN("err_symbol"), LOG_CSTRING, LOG_ITEM_SQL_ERRSYMBOL},
317-
{C_STRING_WITH_LEN("SQL_state"), LOG_CSTRING, LOG_ITEM_SQL_STATE},
318-
{C_STRING_WITH_LEN("OS_errno"), LOG_INTEGER, LOG_ITEM_SYS_ERRNO},
319-
{C_STRING_WITH_LEN("OS_errmsg"), LOG_CSTRING, LOG_ITEM_SYS_STRERROR},
320-
{C_STRING_WITH_LEN("source_file"), LOG_CSTRING, LOG_ITEM_SRC_FILE},
321-
{C_STRING_WITH_LEN("source_line"), LOG_INTEGER, LOG_ITEM_SRC_LINE},
322-
{C_STRING_WITH_LEN("function"), LOG_CSTRING, LOG_ITEM_SRC_FUNC},
323-
{C_STRING_WITH_LEN("subsystem"), LOG_CSTRING, LOG_ITEM_SRV_SUBSYS},
324-
{C_STRING_WITH_LEN("component"), LOG_CSTRING, LOG_ITEM_SRV_COMPONENT},
325-
{C_STRING_WITH_LEN("user"), LOG_LEX_STRING, LOG_ITEM_MSC_USER},
326-
{C_STRING_WITH_LEN("host"), LOG_LEX_STRING, LOG_ITEM_MSC_HOST},
327-
{C_STRING_WITH_LEN("thread"), LOG_INTEGER, LOG_ITEM_SRV_THREAD},
328-
{C_STRING_WITH_LEN("query_id"), LOG_INTEGER, LOG_ITEM_SQL_QUERY_ID},
329-
{C_STRING_WITH_LEN("table"), LOG_CSTRING, LOG_ITEM_SQL_TABLE_NAME},
330-
{C_STRING_WITH_LEN("prio"), LOG_INTEGER, LOG_ITEM_LOG_PRIO},
331-
{C_STRING_WITH_LEN("label"), LOG_CSTRING, LOG_ITEM_LOG_LABEL},
332-
{C_STRING_WITH_LEN("verbatim"), LOG_CSTRING, LOG_ITEM_LOG_VERBATIM},
333-
{C_STRING_WITH_LEN("msg"), LOG_CSTRING, LOG_ITEM_LOG_MESSAGE},
334-
{C_STRING_WITH_LEN("msg_id"), LOG_INTEGER, LOG_ITEM_LOG_LOOKUP},
335-
{C_STRING_WITH_LEN("time"), LOG_CSTRING, LOG_ITEM_LOG_TIMESTAMP},
336-
{C_STRING_WITH_LEN("buffered"), LOG_INTEGER, LOG_ITEM_LOG_BUFFERED},
337-
{C_STRING_WITH_LEN("and_n_more"), LOG_INTEGER, LOG_ITEM_LOG_SUPPRESSED},
313+
{STRING_WITH_LEN("--ERROR--"), LOG_UNTYPED, LOG_ITEM_END},
314+
{STRING_WITH_LEN("log_type"), LOG_INTEGER, LOG_ITEM_LOG_TYPE},
315+
{STRING_WITH_LEN("err_code"), LOG_INTEGER, LOG_ITEM_SQL_ERRCODE},
316+
{STRING_WITH_LEN("err_symbol"), LOG_CSTRING, LOG_ITEM_SQL_ERRSYMBOL},
317+
{STRING_WITH_LEN("SQL_state"), LOG_CSTRING, LOG_ITEM_SQL_STATE},
318+
{STRING_WITH_LEN("OS_errno"), LOG_INTEGER, LOG_ITEM_SYS_ERRNO},
319+
{STRING_WITH_LEN("OS_errmsg"), LOG_CSTRING, LOG_ITEM_SYS_STRERROR},
320+
{STRING_WITH_LEN("source_file"), LOG_CSTRING, LOG_ITEM_SRC_FILE},
321+
{STRING_WITH_LEN("source_line"), LOG_INTEGER, LOG_ITEM_SRC_LINE},
322+
{STRING_WITH_LEN("function"), LOG_CSTRING, LOG_ITEM_SRC_FUNC},
323+
{STRING_WITH_LEN("subsystem"), LOG_CSTRING, LOG_ITEM_SRV_SUBSYS},
324+
{STRING_WITH_LEN("component"), LOG_CSTRING, LOG_ITEM_SRV_COMPONENT},
325+
{STRING_WITH_LEN("user"), LOG_LEX_STRING, LOG_ITEM_MSC_USER},
326+
{STRING_WITH_LEN("host"), LOG_LEX_STRING, LOG_ITEM_MSC_HOST},
327+
{STRING_WITH_LEN("thread"), LOG_INTEGER, LOG_ITEM_SRV_THREAD},
328+
{STRING_WITH_LEN("query_id"), LOG_INTEGER, LOG_ITEM_SQL_QUERY_ID},
329+
{STRING_WITH_LEN("table"), LOG_CSTRING, LOG_ITEM_SQL_TABLE_NAME},
330+
{STRING_WITH_LEN("prio"), LOG_INTEGER, LOG_ITEM_LOG_PRIO},
331+
{STRING_WITH_LEN("label"), LOG_CSTRING, LOG_ITEM_LOG_LABEL},
332+
{STRING_WITH_LEN("verbatim"), LOG_CSTRING, LOG_ITEM_LOG_VERBATIM},
333+
{STRING_WITH_LEN("msg"), LOG_CSTRING, LOG_ITEM_LOG_MESSAGE},
334+
{STRING_WITH_LEN("msg_id"), LOG_INTEGER, LOG_ITEM_LOG_LOOKUP},
335+
{STRING_WITH_LEN("time"), LOG_CSTRING, LOG_ITEM_LOG_TIMESTAMP},
336+
{STRING_WITH_LEN("buffered"), LOG_INTEGER, LOG_ITEM_LOG_BUFFERED},
337+
{STRING_WITH_LEN("and_n_more"), LOG_INTEGER, LOG_ITEM_LOG_SUPPRESSED},
338338
/*
339339
We should never see the following key names in normal operations
340340
(but see the user-specified key instead). These have entries all
@@ -344,10 +344,10 @@ static const log_item_wellknown_key log_item_wellknown_keys[] = {
344344
readability, and allow for easily creating debug info of the form,
345345
"%s:%s=\"%s\"", wellknown_name, item->key, item->value
346346
*/
347-
{C_STRING_WITH_LEN("misc_float"), LOG_FLOAT, LOG_ITEM_GEN_FLOAT},
348-
{C_STRING_WITH_LEN("misc_integer"), LOG_INTEGER, LOG_ITEM_GEN_INTEGER},
349-
{C_STRING_WITH_LEN("misc_string"), LOG_LEX_STRING, LOG_ITEM_GEN_LEX_STRING},
350-
{C_STRING_WITH_LEN("misc_cstring"), LOG_CSTRING, LOG_ITEM_GEN_CSTRING}};
347+
{STRING_WITH_LEN("misc_float"), LOG_FLOAT, LOG_ITEM_GEN_FLOAT},
348+
{STRING_WITH_LEN("misc_integer"), LOG_INTEGER, LOG_ITEM_GEN_INTEGER},
349+
{STRING_WITH_LEN("misc_string"), LOG_LEX_STRING, LOG_ITEM_GEN_LEX_STRING},
350+
{STRING_WITH_LEN("misc_cstring"), LOG_CSTRING, LOG_ITEM_GEN_CSTRING}};
351351

352352
static uint log_item_wellknown_keys_count =
353353
(sizeof(log_item_wellknown_keys) / sizeof(log_item_wellknown_key));
@@ -472,7 +472,7 @@ void log_item_get_float(log_item *li, double *f) {
472472
@param[out] len size_t pointer to store the length of the value in
473473
*/
474474
void log_item_get_string(log_item *li, char **str, size_t *len) {
475-
if ((*str = (char *)li->data.data_string.str) == nullptr)
475+
if ((*str = const_cast<char *>(li->data.data_string.str)) == nullptr)
476476
*len = 0;
477477
else if (li->item_class & LOG_CSTRING)
478478
*len = strlen(li->data.data_string.str);
@@ -3301,15 +3301,15 @@ DEFINE_METHOD(size_t, log_builtins_string_imp::length, (const char *s)) {
33013301
*/
33023302
DEFINE_METHOD(char *, log_builtins_string_imp::find_first,
33033303
(const char *s, int c)) {
3304-
return strchr((char *)s, c);
3304+
return strchr(const_cast<char *>(s), c);
33053305
}
33063306

33073307
/**
33083308
Wrapper for strrchr() - find character in string, from the right
33093309
*/
33103310
DEFINE_METHOD(char *, log_builtins_string_imp::find_last,
33113311
(const char *s, int c)) {
3312-
return strrchr((char *)s, c);
3312+
return strrchr(const_cast<char *>(s), c);
33133313
}
33143314

33153315
/**

components/mysql_server/plugin_registry_service.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -21,6 +21,7 @@ along with this program; if not, write to the Free Software
2121
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2222

2323
#include <mysql/service_plugin_registry.h>
24+
#include <type_traits>
2425
#include "server_component.h" // imp_mysql_server_registry
2526

2627
/**
@@ -72,5 +73,7 @@ SERVICE_TYPE(registry) * mysql_plugin_registry_acquire() {
7273
@ref mysql_service_registry_t::release()
7374
*/
7475
int mysql_plugin_registry_release(SERVICE_TYPE(registry) * reg) {
75-
return imp_mysql_server_registry.release((my_h_service)reg);
76+
using service_type_t = std::remove_const_t<SERVICE_TYPE(registry)>;
77+
return imp_mysql_server_registry.release(
78+
reinterpret_cast<my_h_service>(const_cast<service_type_t *>(reg)));
7679
}

include/sql_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class String {
238238
void mark_as_const() { m_alloced_length = 0; }
239239
/* Returns a pointer to data, may not include NULL terminating character. */
240240
const char *ptr() const { return m_ptr; }
241+
char *ptr() { return m_ptr; }
241242
char *c_ptr() {
242243
DBUG_ASSERT(!m_is_alloced || !m_ptr || !m_alloced_length ||
243244
(m_alloced_length >= (m_length + 1)));

plugin/x/src/sql_data_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ bool Sql_data_context::kill() {
117117
Query_string_builder qb;
118118
qb.put("KILL ").put(mysql_session_id());
119119

120-
data.com_query.query = (char *)qb.get().c_str();
120+
data.com_query.query = qb.get().c_str();
121121
data.com_query.length = static_cast<unsigned int>(qb.get().length());
122122

123123
if (!command_service_run_command(

plugin/x/src/xpl_system_variables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Plugin_system_variables {
9797
template <typename Copy_type>
9898
void Plugin_system_variables::update_func(THD *thd, SYS_VAR *, void *tgt,
9999
const void *save) {
100-
*(Copy_type *)tgt = *(Copy_type *)save;
100+
*static_cast<Copy_type *>(tgt) = *static_cast<const Copy_type *>(save);
101101

102102
std::for_each(
103103
m_callbacks.begin(), m_callbacks.end(),

sql/binlog.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ bool normalize_binlog_name(char *to, const char *from, bool is_relay_log) {
190190
DBUG_ENTER("normalize_binlog_name");
191191
bool error = false;
192192
char buff[FN_REFLEN];
193-
char *ptr = (char *)from;
193+
char *ptr = const_cast<char *>(from);
194194
char *opt_name = is_relay_log ? opt_relay_logname : opt_bin_logname;
195195

196196
DBUG_ASSERT(from);
@@ -3667,7 +3667,6 @@ bool MYSQL_BIN_LOG::open(PSI_file_key log_file_key, const char *log_name,
36673667
if (is_relay_log) flags = flags | MY_REPORT_WAITING_IF_FULL;
36683668

36693669
if (!(name = my_strdup(key_memory_MYSQL_LOG_name, log_name, MYF(MY_WME)))) {
3670-
name = (char *)log_name; // for the error message
36713670
goto err;
36723671
}
36733672

@@ -3703,7 +3702,7 @@ bool MYSQL_BIN_LOG::open(PSI_file_key log_file_key, const char *log_name,
37033702
"there was an encryption error while opening the binlog. "
37043703
"Aborting the server.");
37053704
} else
3706-
LogErr(ERROR_LEVEL, ER_BINLOG_CANT_OPEN_FOR_LOGGING, name, errno);
3705+
LogErr(ERROR_LEVEL, ER_BINLOG_CANT_OPEN_FOR_LOGGING, log_name, errno);
37073706

37083707
my_free(name);
37093708
name = nullptr;
@@ -4790,7 +4789,8 @@ bool MYSQL_BIN_LOG::open_binlog(
47904789
an extension for the binary log files.
47914790
In this case we write a standard header to it.
47924791
*/
4793-
if (m_binlog_file->write((uchar *)BINLOG_MAGIC, BIN_LOG_HEADER_SIZE))
4792+
if (m_binlog_file->write(pointer_cast<const uchar *>(BINLOG_MAGIC),
4793+
BIN_LOG_HEADER_SIZE))
47944794
goto err;
47954795
bytes_written += BIN_LOG_HEADER_SIZE;
47964796
write_file_name_to_index_file = 1;
@@ -5172,7 +5172,8 @@ int MYSQL_BIN_LOG::add_log_to_index(uchar *log_name, size_t log_name_len,
51725172
}
51735173

51745174
if (my_b_write(&crash_safe_index_file, log_name, log_name_len) ||
5175-
my_b_write(&crash_safe_index_file, (uchar *)"\n", 1) ||
5175+
my_b_write(&crash_safe_index_file, pointer_cast<const uchar *>("\n"),
5176+
1) ||
51765177
flush_io_cache(&crash_safe_index_file) ||
51775178
mysql_file_sync(crash_safe_index_file.file, MYF(MY_WME))) {
51785179
LogErr(ERROR_LEVEL, ER_BINLOG_CANT_APPEND_LOG_TO_TMP_INDEX, log_name);
@@ -6680,7 +6681,7 @@ bool MYSQL_BIN_LOG::write_buffer(const char *buf, uint len, Master_info *mi) {
66806681

66816682
// write data
66826683
bool error = false;
6683-
if (m_binlog_file->write((uchar *)buf, len) == 0) {
6684+
if (m_binlog_file->write(pointer_cast<const uchar *>(buf), len) == 0) {
66846685
bytes_written += len;
66856686
error = after_write_to_relay_log(mi);
66866687
} else {
@@ -7270,7 +7271,7 @@ bool MYSQL_BIN_LOG::write_incident(THD *thd, bool need_lock_log,
72707271

72717272
if (!is_open()) DBUG_RETURN(0);
72727273

7273-
LEX_STRING write_error_msg = {(char *)err_msg, strlen(err_msg)};
7274+
LEX_CSTRING write_error_msg = {err_msg, strlen(err_msg)};
72747275
binary_log::Incident_event::enum_incident incident =
72757276
binary_log::Incident_event::INCIDENT_LOST_EVENTS;
72767277
Incident_log_event ev(thd, incident, write_error_msg);

sql/binlog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ class MYSQL_BIN_LOG : public TC_LOG {
843843
bool need_lock_index = true);
844844
inline char *get_index_fname() { return index_file_name; }
845845
inline char *get_log_fname() { return log_file_name; }
846-
inline char *get_name() { return name; }
846+
const char *get_name() const { return name; }
847847
inline mysql_mutex_t *get_log_lock() { return &LOCK_log; }
848848
inline mysql_cond_t *get_log_cond() { return &update_cond; }
849849
inline Binlog_ofile *get_binlog_file() { return m_binlog_file; }

sql/binlog_reader.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Binlog_read_error::Error_type binlog_event_deserialize(
118118

119119
DBUG_ASSERT(fde != 0);
120120
DBUG_PRINT("info", ("binlog_version: %d", fde->binlog_version));
121-
DBUG_DUMP("data", (unsigned char *)buf, event_len);
121+
DBUG_DUMP("data", buffer, event_len);
122122

123123
/* Check the integrity */
124124
if (event_len < LOG_EVENT_MINIMAL_HEADER_LEN) {
@@ -170,7 +170,8 @@ Binlog_read_error::Error_type binlog_event_deserialize(
170170
#endif
171171

172172
if (verify_checksum &&
173-
Log_event_footer::event_checksum_test((uchar *)buf, event_len, alg) &&
173+
Log_event_footer::event_checksum_test(const_cast<uchar *>(buffer),
174+
event_len, alg) &&
174175
/* Skip the crc check when simulating an unknown ignorable log event. */
175176
!DBUG_EVALUATE_IF("simulate_unknown_ignorable_log_event", 1, 0)) {
176177
DBUG_RETURN(Binlog_read_error::CHECKSUM_FAILURE);

sql/ha_ndbcluster_binlog.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7580,13 +7580,13 @@ Ndb_binlog_thread::check_reconnect_incident(THD* thd, injector *inj,
75807580

75817581
// Write an incident event to the binlog since it's not possible to know what
75827582
// has happened in the cluster while not being connected.
7583-
LEX_STRING msg;
7583+
LEX_CSTRING msg;
75847584
switch (incident_id) {
75857585
case MYSQLD_STARTUP:
7586-
msg = {C_STRING_WITH_LEN("mysqld startup")};
7586+
msg = {STRING_WITH_LEN("mysqld startup")};
75877587
break;
75887588
case CLUSTER_DISCONNECT:
7589-
msg = {C_STRING_WITH_LEN("cluster disconnect")};
7589+
msg = {STRING_WITH_LEN("cluster disconnect")};
75907590
break;
75917591
}
75927592
log_verbose(20, "Writing incident for %s", msg.str);
@@ -8201,15 +8201,14 @@ Ndb_binlog_thread::do_run()
82018201
// i_pOp == NULL means an inconsistent epoch or the queue is empty
82028202
else if (i_pOp == NULL && !i_ndb->isConsistent(inconsistent_epoch))
82038203
{
8204-
char errmsg[64];
8205-
uint end= sprintf(&errmsg[0],
8206-
"Detected missing data in GCI %llu, "
8207-
"inserting GAP event", inconsistent_epoch);
8208-
errmsg[end]= '\0';
8204+
char errmsg[72];
8205+
snprintf(errmsg, sizeof(errmsg),
8206+
"Detected missing data in GCI %llu, "
8207+
"inserting GAP event", inconsistent_epoch);
82098208
DBUG_PRINT("info",
82108209
("Detected missing data in GCI %llu, "
82118210
"inserting GAP event", inconsistent_epoch));
8212-
LEX_STRING const msg= { C_STRING_WITH_LEN(errmsg) };
8211+
LEX_CSTRING const msg= { errmsg, strlen(errmsg) };
82138212
inj->record_incident(thd,
82148213
binary_log::Incident_event::INCIDENT_LOST_EVENTS,
82158214
msg);

sql/log_event.cc

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,13 @@ static bool set_thd_db(THD *thd, const char *db, size_t db_len) {
409409
my_casedn_str(system_charset_info, lcase_db_buf);
410410
new_db.str = lcase_db_buf;
411411
} else
412-
new_db.str = (char *)db;
412+
new_db.str = db;
413413

414414
/* This function is called by a slave thread. */
415415
DBUG_ASSERT(thd->rli_slave);
416416

417417
Rpl_filter *rpl_filter = thd->rli_slave->rpl_filter;
418-
new_db.str = (char *)rpl_filter->get_rewrite_db(new_db.str, &new_db.length);
418+
new_db.str = rpl_filter->get_rewrite_db(new_db.str, &new_db.length);
419419

420420
if (lower_case_table_names) {
421421
/* lcase_db_buf != new_db.str means that lcase_db_buf is rewritten. */
@@ -3455,9 +3455,9 @@ bool Query_log_event::write(Basic_ostream *ostream) {
34553455
LEX_CSTRING priv_host = ctx->priv_host();
34563456

34573457
invoker_user.length = priv_user.length;
3458-
invoker_user.str = (char *)priv_user.str;
3458+
invoker_user.str = priv_user.str;
34593459
if (priv_host.str[0] != '\0') {
3460-
invoker_host.str = (char *)priv_host.str;
3460+
invoker_host.str = priv_host.str;
34613461
invoker_host.length = priv_host.length;
34623462
}
34633463
}
@@ -3610,9 +3610,12 @@ bool Query_log_event::write(Basic_ostream *ostream) {
36103610
write_post_header_for_derived(ostream) ||
36113611
wrapper_my_b_safe_write(ostream, start_of_status,
36123612
(uint)(start - start_of_status)) ||
3613-
wrapper_my_b_safe_write(ostream, db ? (uchar *)db : (uchar *)"",
3613+
wrapper_my_b_safe_write(ostream,
3614+
db ? pointer_cast<const uchar *>(db)
3615+
: pointer_cast<const uchar *>(""),
36143616
db_len + 1) ||
3615-
wrapper_my_b_safe_write(ostream, (uchar *)query, q_len) ||
3617+
wrapper_my_b_safe_write(ostream, pointer_cast<const uchar *>(query),
3618+
q_len) ||
36163619
write_footer(ostream))
36173620
? 1
36183621
: 0;
@@ -5464,7 +5467,8 @@ bool Rotate_log_event::write(Basic_ostream *ostream) {
54645467
write_header(ostream, Binary_log_event::ROTATE_HEADER_LEN + ident_len) ||
54655468
wrapper_my_b_safe_write(ostream, (uchar *)buf,
54665469
Binary_log_event::ROTATE_HEADER_LEN) ||
5467-
wrapper_my_b_safe_write(ostream, (uchar *)new_log_ident,
5470+
wrapper_my_b_safe_write(ostream,
5471+
pointer_cast<const uchar *>(new_log_ident),
54685472
(uint)ident_len) ||
54695473
write_footer(ostream));
54705474
}
@@ -6239,7 +6243,8 @@ bool XA_prepare_log_event::write(Basic_ostream *ostream) {
62396243
wrapper_my_b_safe_write(ostream, buf_g, sizeof(buf_g)) ||
62406244
wrapper_my_b_safe_write(ostream, buf_b, sizeof(buf_b)) ||
62416245
wrapper_my_b_safe_write(
6242-
ostream, (uchar *)static_cast<XID *>(xid)->get_data(),
6246+
ostream,
6247+
pointer_cast<const uchar *>(static_cast<XID *>(xid)->get_data()),
62436248
static_cast<XID *>(xid)->get_gtrid_length() +
62446249
static_cast<XID *>(xid)->get_bqual_length()) ||
62456250
write_footer(ostream);
@@ -6472,7 +6477,8 @@ bool User_var_log_event::write(Basic_ostream *ostream) {
64726477

64736478
return (write_header(ostream, event_length) ||
64746479
wrapper_my_b_safe_write(ostream, (uchar *)buf, sizeof(buf)) ||
6475-
wrapper_my_b_safe_write(ostream, (uchar *)name, name_len) ||
6480+
wrapper_my_b_safe_write(ostream, pointer_cast<const uchar *>(name),
6481+
name_len) ||
64766482
wrapper_my_b_safe_write(ostream, (uchar *)buf1, buf1_length) ||
64776483
wrapper_my_b_safe_write(ostream, pos, val_len) ||
64786484
wrapper_my_b_safe_write(ostream, &flags, unsigned_len) ||
@@ -10368,7 +10374,8 @@ static enum_tbl_map_status check_table_map(Relay_log_info const *rli,
1036810374

1036910375
int Table_map_log_event::do_apply_event(Relay_log_info const *rli) {
1037010376
RPL_TABLE_LIST *table_list;
10371-
char *db_mem, *tname_mem, *ptr;
10377+
char *db_mem, *tname_mem;
10378+
const char *ptr;
1037210379
size_t dummy_len;
1037310380
void *memory;
1037410381
DBUG_ENTER("Table_map_log_event::do_apply_event(Relay_log_info*)");
@@ -10393,8 +10400,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) {
1039310400

1039410401
/* rewrite rules changed the database */
1039510402
if (rli->rpl_filter != nullptr &&
10396-
((ptr = (char *)rli->rpl_filter->get_rewrite_db(db_mem, &dummy_len)) !=
10397-
db_mem)) {
10403+
((ptr = rli->rpl_filter->get_rewrite_db(db_mem, &dummy_len)) != db_mem)) {
1039810404
rli->rpl_filter->get_rewrite_db_statistics()->increase_counter();
1039910405
my_stpcpy(db_mem, ptr);
1040010406
}
@@ -12191,8 +12197,9 @@ static bool write_str_at_most_255_bytes(Basic_ostream *ostream, const char *str,
1219112197
uchar tmp[1];
1219212198

1219312199
tmp[0] = (uchar)length;
12194-
return (ostream->write(tmp, sizeof(tmp)) ||
12195-
(length > 0 && ostream->write((uchar *)str, length)));
12200+
return (
12201+
ostream->write(tmp, sizeof(tmp)) ||
12202+
(length > 0 && ostream->write(pointer_cast<const uchar *>(str), length)));
1219612203
}
1219712204

1219812205
bool Incident_log_event::write_data_body(Basic_ostream *ostream) {

sql/log_event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,7 @@ class Incident_log_event : public binary_log::Incident_event, public Log_event {
33173317
}
33183318

33193319
Incident_log_event(THD *thd_arg, enum_incident incident_arg,
3320-
LEX_STRING const msg)
3320+
LEX_CSTRING const msg)
33213321
: binary_log::Incident_event(incident_arg),
33223322
Log_event(thd_arg, LOG_EVENT_NO_FILTER_F, Log_event::EVENT_NO_CACHE,
33233323
Log_event::EVENT_IMMEDIATE_LOGGING, header(), footer()) {

0 commit comments

Comments
 (0)