Commit 769f6d2d authored by Marko Mäkelä's avatar Marko Mäkelä

Fix -Wclass-memaccess in WSREP,InnoDB,XtraDB

parent 0d3972c6
...@@ -460,6 +460,21 @@ struct datafile_cur_t { ...@@ -460,6 +460,21 @@ struct datafile_cur_t {
size_t buf_size; size_t buf_size;
size_t buf_read; size_t buf_read;
size_t buf_offset; size_t buf_offset;
explicit datafile_cur_t(const char* filename = NULL) :
file(), thread_n(0), orig_buf(NULL), buf(NULL), buf_size(0),
buf_read(0), buf_offset(0)
{
memset(rel_path, 0, sizeof rel_path);
if (filename) {
strncpy(abs_path, filename, sizeof abs_path);
abs_path[(sizeof abs_path) - 1] = 0;
} else {
abs_path[0] = '\0';
}
rel_path[0] = '\0';
memset(&statinfo, 0, sizeof statinfo);
}
}; };
static static
...@@ -478,9 +493,7 @@ datafile_open(const char *file, datafile_cur_t *cursor, uint thread_n) ...@@ -478,9 +493,7 @@ datafile_open(const char *file, datafile_cur_t *cursor, uint thread_n)
{ {
ulint success; ulint success;
memset(cursor, 0, sizeof(datafile_cur_t)); new (cursor) datafile_cur_t(file);
strncpy(cursor->abs_path, file, sizeof(cursor->abs_path));
/* Get the relative path for the destination tablespace name, i.e. the /* Get the relative path for the destination tablespace name, i.e. the
one that can be appended to the backup root directory. Non-system one that can be appended to the backup root directory. Non-system
......
...@@ -179,8 +179,7 @@ xb_write_galera_info(bool incremental_prepare) ...@@ -179,8 +179,7 @@ xb_write_galera_info(bool incremental_prepare)
return; return;
} }
memset(&xid, 0, sizeof(xid)); xid.null();
xid.formatID = -1;
if (!trx_sys_read_wsrep_checkpoint(&xid)) { if (!trx_sys_read_wsrep_checkpoint(&xid)) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define HANDLER_INCLUDED #define HANDLER_INCLUDED
/* /*
Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB Copyright (c) 2009, 2018, MariaDB
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
...@@ -602,7 +602,7 @@ struct xid_t { ...@@ -602,7 +602,7 @@ struct xid_t {
bqual_length= b; bqual_length= b;
memcpy(data, d, g+b); memcpy(data, d, g+b);
} }
bool is_null() { return formatID == -1; } bool is_null() const { return formatID == -1; }
void null() { formatID= -1; } void null() { formatID= -1; }
my_xid quick_get_my_xid() my_xid quick_get_my_xid()
{ {
......
...@@ -129,12 +129,11 @@ void wsrep_get_SE_checkpoint(wsrep_uuid_t& uuid, wsrep_seqno_t& seqno) ...@@ -129,12 +129,11 @@ void wsrep_get_SE_checkpoint(wsrep_uuid_t& uuid, wsrep_seqno_t& seqno)
seqno= WSREP_SEQNO_UNDEFINED; seqno= WSREP_SEQNO_UNDEFINED;
XID xid; XID xid;
memset(&xid, 0, sizeof(xid)); xid.null();
xid.formatID= -1;
wsrep_get_SE_checkpoint(xid); wsrep_get_SE_checkpoint(xid);
if (xid.formatID == -1) return; // nil XID if (xid.is_null()) return;
if (!wsrep_is_wsrep_xid(&xid)) if (!wsrep_is_wsrep_xid(&xid))
{ {
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, 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
...@@ -95,10 +95,7 @@ dict_stats_pool_init() ...@@ -95,10 +95,7 @@ dict_stats_pool_init()
/*****************************************************************//** /*****************************************************************//**
Free the resources occupied by the recalc pool, called once during Free the resources occupied by the recalc pool, called once during
thread de-initialization. */ thread de-initialization. */
static static void dict_stats_pool_deinit()
void
dict_stats_pool_deinit()
/*====================*/
{ {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
...@@ -114,8 +111,6 @@ dict_stats_pool_deinit() ...@@ -114,8 +111,6 @@ dict_stats_pool_deinit()
*/ */
recalc_pool_t recalc_empty_pool; recalc_pool_t recalc_empty_pool;
defrag_pool_t defrag_empty_pool; defrag_pool_t defrag_empty_pool;
memset(&recalc_empty_pool, 0, sizeof(recalc_pool_t));
memset(&defrag_empty_pool, 0, sizeof(defrag_pool_t));
recalc_pool.swap(recalc_empty_pool); recalc_pool.swap(recalc_empty_pool);
defrag_pool.swap(defrag_empty_pool); defrag_pool.swap(defrag_empty_pool);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 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
...@@ -347,7 +347,7 @@ trx_sys_update_wsrep_checkpoint( ...@@ -347,7 +347,7 @@ trx_sys_update_wsrep_checkpoint(
mtr_t* mtr) mtr_t* mtr)
{ {
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (xid->formatID != -1 if (!xid->is_null()
&& mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO && mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD) + TRX_SYS_WSREP_XID_MAGIC_N_FLD)
== TRX_SYS_WSREP_XID_MAGIC_N) { == TRX_SYS_WSREP_XID_MAGIC_N) {
...@@ -368,7 +368,7 @@ trx_sys_update_wsrep_checkpoint( ...@@ -368,7 +368,7 @@ trx_sys_update_wsrep_checkpoint(
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
ut_ad(xid && mtr); ut_ad(xid && mtr);
ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const XID *)xid)); ut_a(xid->is_null() || wsrep_is_wsrep_xid((const XID *)xid));
if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD) + TRX_SYS_WSREP_XID_MAGIC_N_FLD)
...@@ -417,8 +417,10 @@ trx_sys_read_wsrep_checkpoint(XID* xid) ...@@ -417,8 +417,10 @@ trx_sys_read_wsrep_checkpoint(XID* xid)
if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD)) + TRX_SYS_WSREP_XID_MAGIC_N_FLD))
!= TRX_SYS_WSREP_XID_MAGIC_N) { != TRX_SYS_WSREP_XID_MAGIC_N) {
memset(xid, 0, sizeof(*xid)); xid->null();
xid->formatID = -1; xid->gtrid_length = 0;
xid->bqual_length = 0;
memset(xid->data, 0, sizeof xid->data);
trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
return false; return false;
......
...@@ -851,8 +851,7 @@ trx_start_low( ...@@ -851,8 +851,7 @@ trx_start_low(
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
memset(&trx->xid, 0, sizeof(trx->xid)); trx->xid.null();
trx->xid.formatID = -1;
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
/* The initial value for trx->no: TRX_ID_MAX is used in /* The initial value for trx->no: TRX_ID_MAX is used in
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, 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
...@@ -95,16 +95,12 @@ dict_stats_pool_init() ...@@ -95,16 +95,12 @@ dict_stats_pool_init()
/*****************************************************************//** /*****************************************************************//**
Free the resources occupied by the recalc pool, called once during Free the resources occupied by the recalc pool, called once during
thread de-initialization. */ thread de-initialization. */
static static void dict_stats_pool_deinit()
void
dict_stats_pool_deinit()
/*===========================*/
{ {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
recalc_pool.clear(); recalc_pool.clear();
defrag_pool.clear(); defrag_pool.clear();
/* /*
recalc_pool may still have its buffer allocated. It will free it when recalc_pool may still have its buffer allocated. It will free it when
its destructor is called. its destructor is called.
...@@ -115,8 +111,6 @@ dict_stats_pool_deinit() ...@@ -115,8 +111,6 @@ dict_stats_pool_deinit()
*/ */
recalc_pool_t recalc_empty_pool; recalc_pool_t recalc_empty_pool;
defrag_pool_t defrag_empty_pool; defrag_pool_t defrag_empty_pool;
memset(&recalc_empty_pool, 0, sizeof(recalc_pool_t));
memset(&defrag_empty_pool, 0, sizeof(defrag_pool_t));
recalc_pool.swap(recalc_empty_pool); recalc_pool.swap(recalc_empty_pool);
defrag_pool.swap(defrag_empty_pool); defrag_pool.swap(defrag_empty_pool);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 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
...@@ -351,7 +351,7 @@ trx_sys_update_wsrep_checkpoint( ...@@ -351,7 +351,7 @@ trx_sys_update_wsrep_checkpoint(
mtr_t* mtr) mtr_t* mtr)
{ {
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (xid->formatID != -1 if (!xid->is_null()
&& mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO && mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD) + TRX_SYS_WSREP_XID_MAGIC_N_FLD)
== TRX_SYS_WSREP_XID_MAGIC_N) { == TRX_SYS_WSREP_XID_MAGIC_N) {
...@@ -372,7 +372,7 @@ trx_sys_update_wsrep_checkpoint( ...@@ -372,7 +372,7 @@ trx_sys_update_wsrep_checkpoint(
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
ut_ad(xid && mtr); ut_ad(xid && mtr);
ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const XID *)xid)); ut_a(xid->is_null() || wsrep_is_wsrep_xid((const XID *)xid));
if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD) + TRX_SYS_WSREP_XID_MAGIC_N_FLD)
...@@ -421,8 +421,10 @@ trx_sys_read_wsrep_checkpoint(XID* xid) ...@@ -421,8 +421,10 @@ trx_sys_read_wsrep_checkpoint(XID* xid)
if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD)) + TRX_SYS_WSREP_XID_MAGIC_N_FLD))
!= TRX_SYS_WSREP_XID_MAGIC_N) { != TRX_SYS_WSREP_XID_MAGIC_N) {
memset(xid, 0, sizeof(*xid)); xid->null();
xid->formatID = -1; xid->gtrid_length = 0;
xid->bqual_length = 0;
memset(xid->data, 0, sizeof xid->data);
trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
return false; return false;
......
...@@ -1041,8 +1041,7 @@ trx_start_low( ...@@ -1041,8 +1041,7 @@ trx_start_low(
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
memset(&trx->xid, 0, sizeof(trx->xid)); trx->xid.null();
trx->xid.formatID = -1;
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
/* The initial value for trx->no: TRX_ID_MAX is used in /* The initial value for trx->no: TRX_ID_MAX is used in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment