Fix -Wclass-memaccess warnings in InnoDB

This commit is contained in:
Marko Mäkelä 2018-08-03 13:06:03 +03:00
parent 814ae57daf
commit 391e60b2db
6 changed files with 38 additions and 8 deletions

View file

@ -2214,8 +2214,8 @@ buf_page_realloc(
if (buf_page_can_relocate(&block->page)) { if (buf_page_can_relocate(&block->page)) {
mutex_enter(&new_block->mutex); mutex_enter(&new_block->mutex);
memcpy(new_block->frame, block->frame, UNIV_PAGE_SIZE); memcpy(new_block->frame, block->frame, srv_page_size);
memcpy(&new_block->page, &block->page, sizeof block->page); new (&new_block->page) buf_page_t(block->page);
/* relocate LRU list */ /* relocate LRU list */
ut_ad(block->page.in_LRU_list); ut_ad(block->page.in_LRU_list);

View file

@ -662,7 +662,7 @@ rtr_adjust_upper_level(
/* Create a memory heap where the data tuple is stored */ /* Create a memory heap where the data tuple is stored */
heap = mem_heap_create(1024); heap = mem_heap_create(1024);
memset(&cursor, 0, sizeof(cursor)); cursor.init();
cursor.thr = sea_cur->thr; cursor.thr = sea_cur->thr;
@ -1379,7 +1379,7 @@ rtr_ins_enlarge_mbr(
rtr_page_cal_mbr(index, block, &new_mbr, heap); rtr_page_cal_mbr(index, block, &new_mbr, heap);
/* Get father block. */ /* Get father block. */
memset(&cursor, 0, sizeof(cursor)); cursor.init();
offsets = rtr_page_get_father_block( offsets = rtr_page_get_father_block(
NULL, heap, index, block, mtr, btr_cur, &cursor); NULL, heap, index, block, mtr, btr_cur, &cursor);

View file

@ -1548,7 +1548,7 @@ rtr_copy_buf(
will be copied. It is also undefined what will happen with the will be copied. It is also undefined what will happen with the
newly memcpy()ed mutex if the source mutex was acquired by newly memcpy()ed mutex if the source mutex was acquired by
(another) thread while it was copied. */ (another) thread while it was copied. */
memcpy(&matches->block.page, &block->page, sizeof(buf_page_t)); new (&matches->block.page) buf_page_t(block->page);
matches->block.frame = block->frame; matches->block.frame = block->frame;
matches->block.unzip_LRU = block->unzip_LRU; matches->block.unzip_LRU = block->unzip_LRU;

View file

@ -926,6 +926,26 @@ struct btr_cur_t {
rtr_info_t* rtr_info; /*!< rtree search info */ rtr_info_t* rtr_info; /*!< rtree search info */
btr_cur_t():thr(NULL), rtr_info(NULL) {} btr_cur_t():thr(NULL), rtr_info(NULL) {}
/* default values */ /* default values */
/** Zero-initialize all fields */
void init()
{
index = NULL;
memset(&page_cur, 0, sizeof page_cur);
purge_node = NULL;
left_block = NULL;
thr = NULL;
flag = btr_cur_method(0);
tree_height = 0;
up_match = 0;
up_bytes = 0;
low_match = 0;
low_bytes = 0;
n_fields = 0;
n_bytes = 0;
fold = 0;
path_arr = NULL;
rtr_info = NULL;
}
}; };
/******************************************************//** /******************************************************//**

View file

@ -543,6 +543,18 @@ struct btr_pcur_t{
/** old_rec_buf size if old_rec_buf is not NULL */ /** old_rec_buf size if old_rec_buf is not NULL */
ulint buf_size; ulint buf_size;
btr_pcur_t() :
btr_cur(), latch_mode(0), old_stored(false), old_rec(NULL),
old_n_fields(0), rel_pos(btr_pcur_pos_t(0)),
block_when_stored(NULL),
modify_clock(0), withdraw_clock(0),
pos_state(BTR_PCUR_NOT_POSITIONED),
search_mode(PAGE_CUR_UNSUPP), trx_if_known(NULL),
old_rec_buf(NULL), buf_size(0)
{
btr_cur.init();
}
/** Return the index of this persistent cursor */ /** Return the index of this persistent cursor */
dict_index_t* index() const { return(btr_cur.index); } dict_index_t* index() const { return(btr_cur.index); }
}; };

View file

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -202,8 +202,6 @@ row_undo_ins_remove_sec_low(
enum row_search_result search_result; enum row_search_result search_result;
const bool modify_leaf = mode == BTR_MODIFY_LEAF; const bool modify_leaf = mode == BTR_MODIFY_LEAF;
memset(&pcur, 0, sizeof(pcur));
row_mtr_start(&mtr, index, !modify_leaf); row_mtr_start(&mtr, index, !modify_leaf);
if (modify_leaf) { if (modify_leaf) {