summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-03-12 16:27:19 +0100
committerSergei Golubchik <serg@mariadb.org>2019-03-14 16:33:17 +0100
commit3d2d060b626a94a19480db55feecc3020440b5c3 (patch)
tree52a1c7c7add53908023d23f90a95a764bbc23d06 /storage
parentddfa722a03ab3649783f8798df02d94a8a8ef6e3 (diff)
downloadmariadb-git-3d2d060b626a94a19480db55feecc3020440b5c3.tar.gz
fix gcc 8 compiler warnings
There were two newly enabled warnings: 1. cast for a function pointers. Affected sql_analyse.h, mi_write.c and ma_write.cc, mf_iocache-t.cc, mysqlbinlog.cc, encryption.cc, etc 2. memcpy/memset of nontrivial structures. Fixed as: * the warning disabled for InnoDB * TABLE, TABLE_SHARE, and TABLE_LIST got a new method reset() which does the bzero(), which is safe for these classes, but any other bzero() will still cause a warning * Table_scope_and_contents_source_st uses `TABLE_LIST *` (trivial) instead of `SQL_I_List<TABLE_LIST>` (not trivial) so it's safe to bzero now. * added casts in debug_sync.cc and sql_select.cc (for JOIN) * move assignment method for MDL_request instead of memcpy() * PARTIAL_INDEX_INTERSECT_INFO::init() instead of bzero() * remove constructor from READ_RECORD() to make it trivial * replace some memcpy() with c++ copy assignments
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/plugutil.cpp2
-rw-r--r--storage/innobase/CMakeLists.txt2
-rw-r--r--storage/maria/ma_write.c17
-rw-r--r--storage/mroonga/ha_mroonga.cpp8
-rw-r--r--storage/myisam/mi_write.c19
-rw-r--r--storage/myisam/myisamlog.c8
-rw-r--r--storage/myisammrg/ha_myisammrg.cc47
-rw-r--r--storage/sequence/sequence.cc9
-rw-r--r--storage/xtradb/CMakeLists.txt2
9 files changed, 58 insertions, 56 deletions
diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp
index 048f00be75f..6790e7eb45c 100644
--- a/storage/connect/plugutil.cpp
+++ b/storage/connect/plugutil.cpp
@@ -526,7 +526,7 @@ BOOL PlugSubSet(void *memp, uint size)
/***********************************************************************/
/* Use it to export a function that do throwing. */
/***********************************************************************/
-void *DoThrow(int n)
+static void *DoThrow(int n)
{
throw n;
} /* end of DoThrow */
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 2a45f05c463..b97b6b68deb 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -84,6 +84,8 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG -DUNIV_SYNC_DEB
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
+MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-class-memaccess")
+
IF(NOT MSVC)
CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN)
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index fde0b3a7afd..1a720101a40 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -1675,14 +1675,15 @@ static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
}
-static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
+static void keys_free(void* key_arg, TREE_FREE mode, void *param_arg)
{
/*
Probably I can use info->lastkey here, but I'm not sure,
and to be safe I'd better use local lastkey.
*/
+ bulk_insert_param *param= (bulk_insert_param*)param_arg;
MARIA_SHARE *share= param->info->s;
- uchar lastkey[MARIA_MAX_KEY_BUFF];
+ uchar lastkey[MARIA_MAX_KEY_BUFF], *key= (uchar*)key_arg;
uint keylen;
MARIA_KEYDEF *keyinfo= share->keyinfo + param->keynr;
MARIA_KEY tmp_key;
@@ -1694,7 +1695,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
mysql_rwlock_wrlock(&keyinfo->root_lock);
keyinfo->version++;
}
- return 0;
+ return;
case free_free:
/* Note: keylen doesn't contain transid lengths */
keylen= _ma_keylength(keyinfo, key);
@@ -1709,13 +1710,14 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
copying middle key up if tree is growing
*/
memcpy(lastkey, key, tmp_key.data_length + tmp_key.ref_length);
- return _ma_ck_write_btree(param->info, &tmp_key);
+ _ma_ck_write_btree(param->info, &tmp_key);
+ return;
case free_end:
if (share->lock_key_trees)
mysql_rwlock_unlock(&keyinfo->root_lock);
- return 0;
+ return;
}
- return 1;
+ return;
}
@@ -1771,8 +1773,7 @@ int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows)
init_tree(&info->bulk_insert[i],
cache_size * key[i].maxlength,
cache_size * key[i].maxlength, 0,
- (qsort_cmp2)keys_compare,
- (tree_element_free) keys_free, (void *)params++, MYF(0));
+ (qsort_cmp2) keys_compare, keys_free, (void *)params++, MYF(0));
}
else
info->bulk_insert[i].root=0;
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp
index 02213f0f179..8b7dd52c8b5 100644
--- a/storage/mroonga/ha_mroonga.cpp
+++ b/storage/mroonga/ha_mroonga.cpp
@@ -2982,9 +2982,9 @@ int ha_mroonga::create_share_for_create() const
TABLE_LIST *table_list = MRN_LEX_GET_TABLE_LIST(lex);
MRN_DBUG_ENTER_METHOD();
wrap_handler_for_create = NULL;
- memset(&table_for_create, 0, sizeof(TABLE));
+ table_for_create.reset();
+ table_share_for_create.reset();
memset(&share_for_create, 0, sizeof(MRN_SHARE));
- memset(&table_share_for_create, 0, sizeof(TABLE_SHARE));
if (table_share) {
table_share_for_create.comment = table_share->comment;
table_share_for_create.connect_string = table_share->connect_string;
@@ -14535,8 +14535,8 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
) {
DBUG_RETURN(HA_ALTER_ERROR);
}
- memcpy(wrap_altered_table, altered_table, sizeof(TABLE));
- memcpy(wrap_altered_table_share, altered_table->s, sizeof(TABLE_SHARE));
+ *wrap_altered_table= *altered_table;
+ *wrap_altered_table_share= *altered_table->s;
mrn_init_sql_alloc(ha_thd(), &(wrap_altered_table_share->mem_root));
n_keys = ha_alter_info->index_drop_count;
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index ff96ee8751b..896f1fdab1f 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -929,13 +929,14 @@ static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
}
-static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
+static void keys_free(void* key_arg, TREE_FREE mode, void *param_arg)
{
/*
Probably I can use info->lastkey here, but I'm not sure,
and to be safe I'd better use local lastkey.
*/
- uchar lastkey[HA_MAX_KEY_BUFF];
+ bulk_insert_param *param= (bulk_insert_param*)param_arg;
+ uchar lastkey[HA_MAX_KEY_BUFF], *key= (uchar*)key_arg;
uint keylen;
MI_KEYDEF *keyinfo;
@@ -946,19 +947,20 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
mysql_rwlock_wrlock(&param->info->s->key_root_lock[param->keynr]);
param->info->s->keyinfo[param->keynr].version++;
}
- return 0;
+ return;
case free_free:
keyinfo=param->info->s->keyinfo+param->keynr;
keylen=_mi_keylength(keyinfo, key);
memcpy(lastkey, key, keylen);
- return _mi_ck_write_btree(param->info,param->keynr,lastkey,
- keylen - param->info->s->rec_reflength);
+ _mi_ck_write_btree(param->info, param->keynr, lastkey,
+ keylen - param->info->s->rec_reflength);
+ return;
case free_end:
if (param->info->s->concurrent_insert)
mysql_rwlock_unlock(&param->info->s->key_root_lock[param->keynr]);
- return 0;
+ return;
}
- return -1;
+ return;
}
@@ -1014,8 +1016,7 @@ int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows)
init_tree(&info->bulk_insert[i],
cache_size * key[i].maxlength,
cache_size * key[i].maxlength, 0,
- (qsort_cmp2)keys_compare,
- (tree_element_free) keys_free, (void *)params++, MYF(0));
+ (qsort_cmp2)keys_compare, keys_free, (void *)params++, MYF(0));
}
else
info->bulk_insert[i].root=0;
diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c
index 7ce03ca9485..f059d6f4c70 100644
--- a/storage/myisam/myisamlog.c
+++ b/storage/myisam/myisamlog.c
@@ -63,7 +63,7 @@ static int test_if_open(struct file_info *key,element_count count,
static void fix_blob_pointers(MI_INFO *isam,uchar *record);
static int test_when_accessed(struct file_info *key,element_count count,
struct st_access_param *access_param);
-static void file_info_free(struct file_info *info);
+static void file_info_free(void*, TREE_FREE, void *);
static int close_some_file(TREE *tree);
static int reopen_closed_file(TREE *tree,struct file_info *file_info);
static int find_record_with_key(struct file_info *file_info,uchar *record);
@@ -330,8 +330,7 @@ static int examine_log(char * file_name, char **table_names)
init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0));
bzero((uchar*) com_count,sizeof(com_count));
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,
- (tree_element_free) file_info_free, NULL,
- MYF(MY_TREE_WITH_DELETE));
+ file_info_free, NULL, MYF(MY_TREE_WITH_DELETE));
(void) init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
0, 0, 0, 0);
@@ -751,8 +750,9 @@ static int test_when_accessed (struct file_info *key,
}
-static void file_info_free(struct file_info *fileinfo)
+static void file_info_free(void* arg, TREE_FREE mode, void *unused)
{
+ struct file_info *fileinfo= arg;
DBUG_ENTER("file_info_free");
if (update)
{
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index bb2ba283f36..d1a3babdb2d 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1466,49 +1466,41 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
if (!(create_info->used_fields & HA_CREATE_USED_UNION))
{
- TABLE_LIST *child_table;
- THD *thd=current_thd;
-
- create_info->merge_list.next= &create_info->merge_list.first;
- create_info->merge_list.elements=0;
+ TABLE_LIST *child_table, *end= NULL;
+ THD *thd=ha_thd();
if (children_l != NULL)
{
- for (child_table= children_l;;
- child_table= child_table->next_global)
+ for (child_table= children_l;; child_table= child_table->next_global)
{
TABLE_LIST *ptr;
if (!(ptr= (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
- goto err;
+ DBUG_VOID_RETURN;
if (!(ptr->table_name= thd->strmake(child_table->table_name,
child_table->table_name_length)))
- goto err;
- if (child_table->db && !(ptr->db= thd->strmake(child_table->db,
- child_table->db_length)))
- goto err;
+ DBUG_VOID_RETURN;
+ if (child_table->db &&
+ !(ptr->db= thd->strmake(child_table->db, child_table->db_length)))
+ DBUG_VOID_RETURN;
- create_info->merge_list.elements++;
- (*create_info->merge_list.next)= ptr;
- create_info->merge_list.next= &ptr->next_local;
+ if (create_info->merge_list)
+ end->next_local= ptr;
+ else
+ create_info->merge_list= ptr;
+ end= ptr;
if (&child_table->next_global == children_last_l)
break;
}
}
- *create_info->merge_list.next=0;
}
if (!(create_info->used_fields & HA_CREATE_USED_INSERT_METHOD))
{
create_info->merge_insert_method = file->merge_insert_method;
}
DBUG_VOID_RETURN;
-
-err:
- create_info->merge_list.elements=0;
- create_info->merge_list.first=0;
- DBUG_VOID_RETURN;
}
@@ -1516,18 +1508,21 @@ int ha_myisammrg::create_mrg(const char *name, HA_CREATE_INFO *create_info)
{
char buff[FN_REFLEN];
const char **table_names, **pos;
- TABLE_LIST *tables= create_info->merge_list.first;
- THD *thd= current_thd;
+ TABLE_LIST *tables= create_info->merge_list;
+ THD *thd= ha_thd();
size_t dirlgt= dirname_length(name);
+ uint ntables= 0;
DBUG_ENTER("ha_myisammrg::create_mrg");
+ for (tables= create_info->merge_list; tables; tables= tables->next_local)
+ ntables++;
+
/* Allocate a table_names array in thread mem_root. */
- if (!(table_names= (const char**)
- thd->alloc((create_info->merge_list.elements+1) * sizeof(char*))))
+ if (!(pos= table_names= (const char**) thd->alloc((ntables + 1) * sizeof(char*))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */
/* Create child path names. */
- for (pos= table_names; tables; tables= tables->next_local)
+ for (tables= create_info->merge_list; tables; tables= tables->next_local)
{
const char *table_name= buff;
diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc
index 8d9465f08c5..6a8625ce9b4 100644
--- a/storage/sequence/sequence.cc
+++ b/storage/sequence/sequence.cc
@@ -348,7 +348,9 @@ static int discover_table_existence(handlerton *hton, const char *db,
return !parse_table_name(table_name, strlen(table_name), &from, &to, &step);
}
-static int dummy_ret_int() { return 0; }
+static int dummy_commit_rollback(handlerton *, THD *, bool) { return 0; }
+
+static int dummy_savepoint(handlerton *, THD *, void *) { return 0; }
/*****************************************************************************
Example of a simple group by handler for queries like:
@@ -487,10 +489,9 @@ static int init(void *p)
hton->create= create_handler;
hton->discover_table= discover_table;
hton->discover_table_existence= discover_table_existence;
- hton->commit= hton->rollback=
- (int (*)(handlerton *, THD *, bool)) &dummy_ret_int;
+ hton->commit= hton->rollback= dummy_commit_rollback;
hton->savepoint_set= hton->savepoint_rollback= hton->savepoint_release=
- (int (*)(handlerton *, THD *, void *)) &dummy_ret_int;
+ dummy_savepoint;
hton->create_group_by= create_group_by_handler;
return 0;
}
diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt
index 96856a92239..77fd2ba29af 100644
--- a/storage/xtradb/CMakeLists.txt
+++ b/storage/xtradb/CMakeLists.txt
@@ -89,6 +89,8 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG -DUNIV_SYNC_DEB
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
+MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-class-memaccess")
+
IF(NOT MSVC)
CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN)