Skip to content

Commit dc467bd

Browse files
author
Steinar H. Gunderson
committed
Bug #26826272: REMOVE GCC 8 WARNINGS [noclose]
Fix even more GCC 8 warnings. This marks the end of all the simple cases outside of InnoDB; all remaining warnings are either nontrivial or inside InnoDB. Change-Id: I50773d860fec42401bc2a6731d7b4ab1d0532d09
1 parent 1de634c commit dc467bd

16 files changed

+17
-45
lines changed

sql/dd_sp.cc

-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ static void prepare_type_string_from_dd_param(THD *thd,
170170
// Get type in string format.
171171
TABLE table;
172172
TABLE_SHARE share;
173-
memset(&table, 0, sizeof(table));
174-
memset(&share, 0, sizeof(share));
175173
table.in_use= thd;
176174
table.s= &share;
177175

sql/handler.cc

-2
Original file line numberDiff line numberDiff line change
@@ -2630,8 +2630,6 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
26302630
TABLE_SHARE dummy_share;
26312631
DBUG_ENTER("ha_delete_table");
26322632

2633-
memset(&dummy_table, 0, sizeof(dummy_table));
2634-
memset(&dummy_share, 0, sizeof(dummy_share));
26352633
dummy_table.s= &dummy_share;
26362634

26372635
/* DB_TYPE_UNKNOWN is used in ALTER TABLE when renaming only .frm files */

sql/item_func.cc

-1
Original file line numberDiff line numberDiff line change
@@ -8868,7 +8868,6 @@ bool check_table_and_trigger_access(Item **args,
88688868
DBUG_RETURN(false);
88698869

88708870
TABLE_LIST table_list;
8871-
memset(&table_list, 0, sizeof (table_list));
88728871
table_list.db= schema_name_ptr->ptr();
88738872
table_list.db_length= schema_name_ptr->length();
88748873
table_list.table_name= table_name_ptr->ptr();

sql/item_strfunc.cc

-1
Original file line numberDiff line numberDiff line change
@@ -4653,7 +4653,6 @@ String *Item_func_get_dd_column_privileges::val_str(String *str)
46534653

46544654
THD *thd= current_thd;
46554655
GRANT_INFO grant_info;
4656-
memset(&grant_info, 0, sizeof (grant_info));
46574656
fill_effective_table_privileges(thd,
46584657
&grant_info,
46594658
schema_name_ptr->c_ptr_safe(),

sql/mysqld.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -8058,7 +8058,7 @@ static int mysql_init_variables()
80588058
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
80598059
prepared_stmt_count= 0;
80608060
mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
8061-
memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
8061+
new (&mysql_tmpdir_list) MY_TMPDIR;
80628062
memset(&global_status_var, 0, sizeof(global_status_var));
80638063
opt_large_pages= 0;
80648064
opt_super_large_pages= 0;

sql/partition_info.cc

+5-9
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ partition_info *partition_info::get_clone(THD *thd, bool reset /* = false */)
7373
DBUG_ENTER("partition_info::get_clone");
7474
List_iterator<partition_element> part_it(partitions);
7575
partition_element *part;
76-
partition_info *clone= new (*THR_MALLOC) partition_info();
76+
partition_info *clone= new (*THR_MALLOC) partition_info(*this);
7777
if (!clone)
7878
{
7979
mem_alloc_error(sizeof(partition_info));
8080
DBUG_RETURN(NULL);
8181
}
82-
memcpy(clone, this, sizeof(partition_info));
83-
memset(&(clone->read_partitions), 0, sizeof(clone->read_partitions));
84-
memset(&(clone->lock_partitions), 0, sizeof(clone->lock_partitions));
82+
new (&(clone->read_partitions)) MY_BITMAP;
83+
new (&(clone->lock_partitions)) MY_BITMAP;
8584
clone->bitmaps_are_initialized= FALSE;
8685
clone->partitions.empty();
8786
clone->temp_partitions.empty();
@@ -90,13 +89,12 @@ partition_info *partition_info::get_clone(THD *thd, bool reset /* = false */)
9089
{
9190
List_iterator<partition_element> subpart_it(part->subpartitions);
9291
partition_element *subpart;
93-
partition_element *part_clone= new (*THR_MALLOC) partition_element();
92+
partition_element *part_clone= new (*THR_MALLOC) partition_element(*part);
9493
if (!part_clone)
9594
{
9695
mem_alloc_error(sizeof(partition_element));
9796
DBUG_RETURN(NULL);
9897
}
99-
memcpy(part_clone, part, sizeof(partition_element));
10098

10199
/* Explicitly copy the tablespace name, use the thd->mem_root. */
102100
if (part->tablespace_name != nullptr)
@@ -125,13 +123,12 @@ partition_info *partition_info::get_clone(THD *thd, bool reset /* = false */)
125123
part_clone->subpartitions.empty();
126124
while ((subpart= (subpart_it++)))
127125
{
128-
partition_element *subpart_clone= new (*THR_MALLOC) partition_element();
126+
partition_element *subpart_clone= new (*THR_MALLOC) partition_element(*subpart);
129127
if (!subpart_clone)
130128
{
131129
mem_alloc_error(sizeof(partition_element));
132130
DBUG_RETURN(NULL);
133131
}
134-
memcpy(subpart_clone, subpart, sizeof(partition_element));
135132

136133
/* Explicitly copy the tablespace name, use the thd->mem_root. */
137134
if (subpart->tablespace_name != nullptr)
@@ -1885,7 +1882,6 @@ void partition_info::print_no_partition_found(THD *thd, TABLE *table_arg)
18851882
char *buf_ptr= (char*)&buf;
18861883
TABLE_LIST table_list;
18871884

1888-
memset(&table_list, 0, sizeof(table_list));
18891885
table_list.db= table_arg->s->db.str;
18901886
table_list.table_name= table_arg->s->table_name.str;
18911887

sql/records.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ bool init_read_record(READ_RECORD *info,THD *thd,
209209
if (!table)
210210
table= qep_tab->table();
211211

212-
memset(info, 0, sizeof(*info));
212+
new (info) READ_RECORD;
213213
info->thd=thd;
214214
info->table=table;
215215
info->forms= &info->table; /* Only one table */

sql/sql_alter.cc

-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ bool Sql_cmd_alter_table::execute(THD *thd)
290290
// Rename of table
291291
DBUG_ASSERT(alter_info.flags & Alter_info::ALTER_RENAME);
292292
TABLE_LIST tmp_table;
293-
memset(&tmp_table, 0, sizeof(tmp_table));
294293
tmp_table.table_name= alter_info.new_table_name.str;
295294
tmp_table.db= alter_info.new_db_name.str;
296295
tmp_table.grant.privilege= priv;

sql/sql_delete.cc

-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ bool Sql_cmd_delete::prepare_inner(THD *thd)
788788
List<Item> fields;
789789
List<Item> all_fields;
790790

791-
memset(&tables, 0, sizeof(tables));
792791
tables.table = table_list->table;
793792
tables.alias = table_list->alias;
794793

sql/sql_insert.cc

-2
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
25442544

25452545
DBUG_ENTER("create_table_from_items");
25462546

2547-
memset(&tmp_table, 0, sizeof(tmp_table));
25482547
tmp_table.s= &share;
25492548
init_tmp_table_share(thd, &share, "", 0, "", "", nullptr);
25502549

@@ -2947,7 +2946,6 @@ int Query_result_create::binlog_show_create_table()
29472946
int result;
29482947
TABLE_LIST tmp_table_list;
29492948

2950-
memset(&tmp_table_list, 0, sizeof(tmp_table_list));
29512949
tmp_table_list.table= table;
29522950
query.length(0); // Have to zero it since constructor doesn't
29532951

sql/sql_plugin.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,6 @@ static bool plugin_add(MEM_ROOT *tmp_root,
979979
mysql_mutex_lock(&LOCK_plugin);
980980
DBUG_RETURN(TRUE);
981981
}
982-
/* Clear the whole struct to catch future extensions. */
983-
memset(&tmp, 0, sizeof(tmp));
984982
if (! (tmp.plugin_dl= plugin_dl_add(dl, report)))
985983
DBUG_RETURN(TRUE);
986984
/* Find plugin by name */
@@ -1545,7 +1543,6 @@ bool plugin_register_builtin_and_init_core_se(int *argc, char **argv)
15451543
for (struct st_mysql_plugin *plugin= *builtins; plugin->info; plugin++)
15461544
{
15471545
struct st_plugin_int tmp;
1548-
memset(&tmp, 0, sizeof(tmp));
15491546
tmp.plugin= plugin;
15501547
tmp.name.str= (char *)plugin->name;
15511548
tmp.name.length= strlen(plugin->name);
@@ -1702,8 +1699,7 @@ static bool register_builtin(st_mysql_plugin *plugin,
17021699
DBUG_RETURN(true);
17031700

17041701
*ptr= plugin_array->back()=
1705-
static_cast<st_plugin_int*>(memdup_root(&plugin_mem_root, tmp,
1706-
sizeof(st_plugin_int)));
1702+
new (&plugin_mem_root) st_plugin_int(std::move(*tmp));
17071703

17081704
plugin_hash[plugin->type]->emplace(to_string((*ptr)->name), *ptr);
17091705

sql/sql_plugin_ref.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ enum enum_plugin_load_option {
3636

3737
struct st_plugin_int
3838
{
39-
LEX_STRING name;
40-
st_mysql_plugin *plugin;
41-
st_plugin_dl *plugin_dl;
42-
uint state;
43-
uint ref_count; /* number of threads using the plugin */
44-
void *data; /* plugin type specific, e.g. handlerton */
39+
LEX_STRING name{nullptr, 0};
40+
st_mysql_plugin *plugin{nullptr};
41+
st_plugin_dl *plugin_dl{nullptr};
42+
uint state{0};
43+
uint ref_count{0}; /* number of threads using the plugin */
44+
void *data{nullptr}; /* plugin type specific, e.g. handlerton */
4545
MEM_ROOT mem_root; /* memory for dynamic plugin structures */
46-
sys_var *system_vars; /* server variables for this plugin */
47-
enum_plugin_load_option load_option; /* OFF, ON, FORCE, F+PERMANENT */
46+
sys_var *system_vars{nullptr}; /* server variables for this plugin */
47+
enum_plugin_load_option load_option{PLUGIN_OFF}; /* OFF, ON, FORCE, F+PERMANENT */
4848
};
4949

5050
/*

sql/sql_servers.cc

-2
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ static bool close_cached_connection_tables(THD *thd,
384384
DBUG_ENTER("close_cached_connection_tables");
385385
DBUG_ASSERT(thd);
386386

387-
memset(&tmp, 0, sizeof(TABLE_LIST));
388-
389387
mysql_mutex_lock(&LOCK_open);
390388

391389
for (const auto &key_and_value : *table_def_cache)

sql/sql_show.cc

-5
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,6 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db,
456456
wild_length= strlen(wild);
457457
}
458458

459-
460-
461-
memset(&table_list, 0, sizeof(table_list));
462-
463459
if (!(dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0))))
464460
{
465461
if (my_errno() == ENOENT)
@@ -3626,7 +3622,6 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex,
36263622
if (!(thd->col_access & TABLE_ACLS))
36273623
{
36283624
TABLE_LIST table_list;
3629-
memset(&table_list, 0, sizeof(table_list));
36303625
table_list.db= db_name->str;
36313626
table_list.db_length= db_name->length;
36323627
table_list.table_name= const_cast<char*>(name->c_str());

sql/trigger.cc

-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ Trigger::Trigger(const LEX_CSTRING &trigger_name,
456456
m_parse_error_message[0]= 0;
457457

458458
construct_definer_value(mem_root, &m_definer, definer_user, definer_host);
459-
memset(&m_subject_table_grant, 0, sizeof (m_subject_table_grant));
460459
}
461460

462461

sql/tztime.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -1564,10 +1564,9 @@ class Tz_names_entry
15641564
static void
15651565
tz_init_table_list(TABLE_LIST *tz_tabs)
15661566
{
1567-
memset(tz_tabs, 0, sizeof(TABLE_LIST) * MY_TZ_TABLES_COUNT);
1568-
15691567
for (int i= 0; i < MY_TZ_TABLES_COUNT; i++)
15701568
{
1569+
new (&tz_tabs[i]) TABLE_LIST;
15711570
tz_tabs[i].alias= tz_tabs[i].table_name= tz_tables_names[i].str;
15721571
tz_tabs[i].table_name_length= tz_tables_names[i].length;
15731572
tz_tabs[i].db= tz_tables_db_name.str;
@@ -1694,7 +1693,6 @@ my_tz_init(THD *org_thd, const char *default_tzname, bool bootstrap)
16941693
leap seconds shared by all time zones.
16951694
*/
16961695
thd->set_db(db);
1697-
memset(&tz_tables[0], 0, sizeof(TABLE_LIST));
16981696
tz_tables[0].alias= tz_tables[0].table_name=
16991697
(char*)"time_zone_leap_second";
17001698
tz_tables[0].table_name_length= 21;

0 commit comments

Comments
 (0)