diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index bedb8ffb2ec..fee3b141206 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -334,7 +334,6 @@ get_mysql_vars(MYSQL *connection) char *version_comment_var = NULL; char *innodb_version_var = NULL; char *have_backup_locks_var = NULL; - char *have_backup_safe_binlog_info_var = NULL; char *log_bin_var = NULL; char *lock_wait_timeout_var= NULL; char *wsrep_on_var = NULL; diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 7f3a04ff7ea..2af8c22533f 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2014,7 +2014,6 @@ xtrabackup_read_metadata(char *filename) { FILE *fp; my_bool r = TRUE; - int t; fp = fopen(filename,"r"); if(!fp) { @@ -5319,27 +5318,6 @@ innodb_free_param() } -/** Store the current binary log coordinates in a specified file. -@param[in] filename file name -@param[in] name binary log file name -@param[in] pos binary log file position -@return whether the operation succeeded */ -static bool -store_binlog_info(const char* filename, const char* name, ulonglong pos) -{ - FILE *fp = fopen(filename, "w"); - - if (!fp) { - msg("mariabackup: failed to open '%s'", filename); - return(false); - } - - fprintf(fp, "%s\t%llu\n", name, pos); - fclose(fp); - - return(true); -} - /** Check if file exists*/ static bool file_exists(std::string name) { diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 78eb58506ff..e236010c459 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -680,11 +680,11 @@ static int alloc_tmp_paths(THD *thd, uint n_paths, *paths= (json_path_with_flags *) alloc_root(root, sizeof(json_path_with_flags) * n_paths); - *tmp_paths= (String *) alloc_root(root, sizeof(String) * n_paths); + + *tmp_paths= new (root) String[n_paths]; if (*paths == 0 || *tmp_paths == 0) return 1; - bzero(*tmp_paths, sizeof(String) * n_paths); for (uint c_path=0; c_path < n_paths; c_path++) (*tmp_paths)[c_path].set_charset(&my_charset_utf8_general_ci); } diff --git a/sql/opt_range.cc b/sql/opt_range.cc index da5e9707595..d7bbdeb82a4 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1348,7 +1348,6 @@ QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT(THD *thd_param, TABLE *table) DBUG_ENTER("QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT"); index= MAX_KEY; head= table; - bzero(&read_record, sizeof(read_record)); init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC)); DBUG_VOID_RETURN; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1d1cca0568e..ae6030115fa 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -772,7 +772,7 @@ enum enum_acl_tables ROLES_MAPPING_TABLE, TABLES_MAX // <== always the last }; -// bits for open_grant_tables + static const int Table_user= 1 << USER_TABLE; static const int Table_db= 1 << DB_TABLE; static const int Table_tables_priv= 1 << TABLES_PRIV_TABLE; @@ -853,7 +853,7 @@ class Grant_table_base Grant_table_base() : start_privilege_column(0), num_privilege_cols(0) { - bzero(&tl, sizeof(tl)); + tl.reset(); }; /* Initialization sequence common for all grant tables. This should be called diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 69aa8a97a87..1dfd6520e17 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2447,7 +2447,7 @@ bool JOIN::make_aggr_tables_info() aggr_tables++; curr_tab= join_tab + exec_join_tab_cnt(); - bzero(curr_tab, sizeof(JOIN_TAB)); + bzero((void*)curr_tab, sizeof(JOIN_TAB)); curr_tab->ref.key= -1; curr_tab->join= this; @@ -2535,7 +2535,7 @@ bool JOIN::make_aggr_tables_info() { aggr_tables++; curr_tab= join_tab + exec_join_tab_cnt(); - bzero(curr_tab, sizeof(JOIN_TAB)); + bzero((void*)curr_tab, sizeof(JOIN_TAB)); curr_tab->ref.key= -1; if (only_const_tables()) first_select= sub_select_postjoin_aggr; @@ -2663,7 +2663,7 @@ bool JOIN::make_aggr_tables_info() curr_tab++; aggr_tables++; - bzero(curr_tab, sizeof(JOIN_TAB)); + bzero((void*)curr_tab, sizeof(JOIN_TAB)); curr_tab->ref.key= -1; /* group data to new table */ @@ -17448,7 +17448,7 @@ bool Virtual_tmp_table::init(uint field_count) &bitmaps, bitmap_buffer_size(field_count) * 6, NullS)) return true; - bzero(s, sizeof(*s)); + s->reset(); s->blob_field= blob_field; setup_tmp_table_column_bitmaps(this, bitmaps, field_count); m_alloced_field_count= field_count; diff --git a/sql/sql_select.h b/sql/sql_select.h index 09e8f5a3e10..5eea5937ea6 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2046,9 +2046,9 @@ public: static void *operator new(size_t size, THD *thd) throw(); static void operator delete(void *ptr, size_t size) {TRASH_FREE(ptr, size);} - Virtual_tmp_table(THD *thd) + Virtual_tmp_table(THD *thd) : m_alloced_field_count(0) { - bzero(this, sizeof(*this)); + reset(); temp_pool_slot= MY_BIT_NONE; in_use= thd; } diff --git a/sql/sql_string.h b/sql/sql_string.h index ea810f15f80..0065b1424ce 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -27,6 +27,7 @@ #include "m_ctype.h" /* my_charset_bin */ #include "my_sys.h" /* alloc_root, my_free, my_realloc */ #include "m_string.h" /* TRASH */ +#include "sql_list.h" class String; typedef struct st_io_cache IO_CACHE; @@ -129,7 +130,7 @@ uint convert_to_printable(char *to, size_t to_len, const char *from, size_t from_len, CHARSET_INFO *from_cs, size_t nbytes= 0); -class String +class String : public Sql_alloc { char *Ptr; uint32 str_length,Alloced_length, extra_alloc; @@ -179,16 +180,6 @@ public: alloced= thread_specific= 0; str_charset=str.str_charset; } - static void *operator new(size_t size, MEM_ROOT *mem_root) throw () - { return (void*) alloc_root(mem_root, (uint) size); } - static void operator delete(void *ptr_arg, size_t size) - { - (void) ptr_arg; - (void) size; - TRASH_FREE(ptr_arg, size); - } - static void operator delete(void *, MEM_ROOT *) - { /* never called */ } ~String() { free(); } /* Mark variable thread specific it it's not allocated already */ diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index bfebc2e1b12..bb6a06240af 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -5782,7 +5782,7 @@ AIO::AIO( m_not_full = os_event_create("aio_not_full"); m_is_empty = os_event_create("aio_is_empty"); - memset(&m_slots[0], 0x0, sizeof(m_slots[0]) * m_slots.size()); + memset((void*)&m_slots[0], 0x0, sizeof(m_slots[0]) * m_slots.size()); #ifdef LINUX_NATIVE_AIO memset(&m_events[0], 0x0, sizeof(m_events[0]) * m_events.size()); #endif /* LINUX_NATIVE_AIO */ diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 46077a2671e..0c59398b90b 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -2591,7 +2591,7 @@ ha_mroonga::~ha_mroonga() } if (blob_buffers) { - ::delete [] blob_buffers; + delete [] blob_buffers; } grn_obj_unlink(ctx, &top_left_point); grn_obj_unlink(ctx, &bottom_right_point); @@ -4726,11 +4726,8 @@ int ha_mroonga::storage_open_columns(void) if (table_share->blob_fields) { - if (blob_buffers) - { - delete [] blob_buffers; - } - if (!(blob_buffers = new String[n_columns])) + DBUG_ASSERT(!blob_buffers); + if (!(blob_buffers = new (&table->mem_root) String[n_columns])) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 768c967ef63..6ce00cb4d1c 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -676,7 +676,7 @@ static void rocksdb_set_rocksdb_info_log_level( RDB_MUTEX_LOCK_CHECK(rdb_sysvars_mutex); rocksdb_info_log_level = *static_cast(save); rocksdb_db_options->info_log->SetInfoLogLevel( - static_cast(rocksdb_info_log_level)); + static_cast(rocksdb_info_log_level)); RDB_MUTEX_UNLOCK_CHECK(rdb_sysvars_mutex); } diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 4ca37897edd..8e286547940 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -127,9 +127,9 @@ Rdb_key_def::Rdb_key_def(const Rdb_key_def &k) m_total_index_flags_length == 0); if (k.m_pack_info) { const size_t size = sizeof(Rdb_field_packing) * k.m_key_parts; - m_pack_info = - reinterpret_cast(my_malloc(size, MYF(0))); - memcpy(m_pack_info, k.m_pack_info, size); + void *pack_info= my_malloc(size, MYF(0)); + memcpy(pack_info, k.m_pack_info, size); + m_pack_info = reinterpret_cast(pack_info); } if (k.m_pk_part_no) { @@ -1090,7 +1090,7 @@ uint Rdb_key_def::pack_record( // Insert TTL timestamp if (has_ttl() && ttl_bytes) { write_index_flag_field(unpack_info, - reinterpret_cast(ttl_bytes), + reinterpret_cast(ttl_bytes), Rdb_key_def::TTL_FLAG); } } diff --git a/storage/rocksdb/rdb_threads.cc b/storage/rocksdb/rdb_threads.cc index 276f228d7cc..2214ce1a043 100644 --- a/storage/rocksdb/rdb_threads.cc +++ b/storage/rocksdb/rdb_threads.cc @@ -28,7 +28,7 @@ namespace myrocks { void *Rdb_thread::thread_func(void *const thread_ptr) { DBUG_ASSERT(thread_ptr != nullptr); - Rdb_thread *const thread = static_cast(thread_ptr); + Rdb_thread *const thread = static_cast(thread_ptr); if (!thread->m_run_once.exchange(true)) { thread->setname(); thread->run();