Skip to content

Commit 9dfef6e

Browse files
committed
Fix -Wclass-memaccess warnings in InnoDB,XtraDB
1 parent b963cba commit 9dfef6e

File tree

14 files changed

+34
-12
lines changed

14 files changed

+34
-12
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ buf_relocate(
16111611
}
16121612
#endif /* UNIV_DEBUG */
16131613

1614-
memcpy(dpage, bpage, sizeof *dpage);
1614+
new (dpage) buf_page_t(*bpage);
16151615

16161616
ut_d(bpage->in_LRU_list = FALSE);
16171617
ut_d(bpage->in_page_hash = FALSE);

storage/innobase/buf/buf0lru.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ buf_LRU_free_page(
18491849
} else if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
18501850
b = buf_page_alloc_descriptor();
18511851
ut_a(b);
1852-
memcpy(b, bpage, sizeof *b);
1852+
new (b) buf_page_t(*bpage);
18531853
}
18541854

18551855
ut_ad(buf_pool_mutex_own(buf_pool));

storage/innobase/include/dict0mem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ struct dict_field_t{
509509
unsignedfixed_len:10;/*!< 0 or the fixed length of the
510510
column if smaller than
511511
DICT_ANTELOPE_MAX_INDEX_COL_LEN */
512+
513+
/** Zero-initialize all fields */
514+
dict_field_t() : col(NULL), name(NULL), prefix_len(0), fixed_len(0) {}
512515
};
513516

514517
/**********************************************************************//**

storage/innobase/include/row0ftsort.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2015, 2018, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -106,6 +107,14 @@ struct fts_tokenize_ctx {
106107
ib_rbt_t*cached_stopword;/*!< in: stopword list */
107108
dfield_tsort_field[FTS_NUM_FIELDS_SORT];
108109
/*!< in: sort field */
110+
111+
fts_tokenize_ctx() :
112+
processed_len(0), init_pos(0), buf_used(0),
113+
rows_added(), cached_stopword(NULL), sort_field()
114+
{
115+
memset(rows_added, 0, sizeof rows_added);
116+
memset(sort_field, 0, sizeof sort_field);
117+
}
109118
};
110119

111120
typedef struct fts_tokenize_ctx fts_tokenize_ctx_t;

storage/innobase/row/row0ftsort.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,6 @@ fts_parallel_tokenization(
638638
merge_file = psort_info->merge_file;
639639
blob_heap = mem_heap_create(512);
640640
memset(&doc, 0, sizeof(doc));
641-
memset(&t_ctx, 0, sizeof(t_ctx));
642641
memset(mycount, 0, FTS_NUM_AUX_INDEX * sizeof(int));
643642

644643
doc.charset = fts_index_get_charset(

storage/innobase/row/row0import.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,8 +2620,6 @@ row_import_cfg_read_index_fields(
26202620

26212621
dict_field_t* field = index->m_fields;
26222622

2623-
memset(field, 0x0, sizeof(*field) * n_fields);
2624-
26252623
for (ulint i = 0; i < n_fields; ++i, ++field) {
26262624
byte* ptr = row;
26272625

@@ -2639,6 +2637,8 @@ row_import_cfg_read_index_fields(
26392637
return(DB_IO_ERROR);
26402638
}
26412639

2640+
new (field) dict_field_t();
2641+
26422642
field->prefix_len = mach_read_from_4(ptr);
26432643
ptr += sizeof(ib_uint32_t);
26442644

storage/innobase/trx/trx0trx.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ trx_create(void)
140140

141141
trx->global_read_view_heap = mem_heap_create(256);
142142

143-
trx->xid.formatID = -1;
143+
trx->xid.null();
144144

145145
trx->op_info = "";
146146

storage/xtradb/buf/buf0buf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ buf_relocate(
17181718
}
17191719
#endif /* UNIV_DEBUG */
17201720

1721-
memcpy(dpage, bpage, sizeof *dpage);
1721+
new (dpage) buf_page_t(*bpage);
17221722

17231723
ut_d(bpage->in_LRU_list = FALSE);
17241724
ut_d(bpage->in_page_hash = FALSE);

storage/xtradb/buf/buf0lru.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ buf_LRU_free_page(
21122112
}
21132113

21142114
if (b) {
2115-
memcpy(b, bpage, sizeof *b);
2115+
new (b) buf_page_t(*bpage);
21162116
}
21172117

21182118
if (!buf_LRU_block_remove_hashed(bpage, zip)) {

storage/xtradb/include/dict0mem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ struct dict_field_t{
516516
unsignedfixed_len:10;/*!< 0 or the fixed length of the
517517
column if smaller than
518518
DICT_ANTELOPE_MAX_INDEX_COL_LEN */
519+
520+
/** Zero-initialize all fields */
521+
dict_field_t() : col(NULL), name(NULL), prefix_len(0), fixed_len(0) {}
519522
};
520523

521524
/**********************************************************************//**

0 commit comments

Comments
 (0)