From 2ffd6671a12ff9d63567a17feed7fea863b49c59 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Fri, 11 Sep 2015 07:35:09 +0100 Subject: [PATCH] Bug#21803314: FIX NEW COMPILATION ERRORS AND WARNINGS WITH CLANG 3.7 Fix a number of new errors and warnings reported by Clang 3.7: -Wconditional-uninitialized and -Wshift-negative-value. --- libmysql/libmysql.c | 4 ++-- mysys/my_copy.c | 1 + storage/innobase/dict/dict0load.cc | 2 +- storage/innobase/include/dict0mem.h | 12 ++++++------ storage/innobase/include/fsp0types.h | 14 +++++++------- storage/myisam/mi_check.c | 1 + testclients/mysql_client_test.c | 8 ++++---- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e2de196773c..190282eddbe 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1092,8 +1092,8 @@ my_bool STDCALL mysql_embedded(void) void my_net_local_init(NET *net) { - ulong local_net_buffer_length; - ulong local_max_allowed_packet; + ulong local_net_buffer_length= 0; + ulong local_max_allowed_packet= 0; (void) mysql_get_option(NULL, MYSQL_OPT_MAX_ALLOWED_PACKET, &local_max_allowed_packet); diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 9b1a91df0e5..a416389c4b9 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -57,6 +57,7 @@ int my_copy(const char *from, const char *to, myf MyFlags) DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); from_file=to_file= -1; + memset(&new_stat_buff, 0, sizeof(MY_STAT)); DBUG_ASSERT(!(MyFlags & (MY_FNABP | MY_NABP))); /* for my_read/my_write */ if (MyFlags & MY_HOLD_ORIGINAL_MODES) /* Copy stat if possible */ new_file_stat= MY_TEST(my_stat((char*) to, &new_stat_buff, MYF(0))); diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index be0e826eac2..6cbcb2ec231 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2354,7 +2354,7 @@ dict_load_index_low( goto err_len; } type = mach_read_from_4(field); - if (type & (~0 << DICT_IT_BITS)) { + if (type & (~0U << DICT_IT_BITS)) { return("unknown SYS_INDEXES.TYPE bits"); } diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index ce8ee53e356..c45e95c8a48 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -171,23 +171,23 @@ to open the table and allows InnoDB to quickly find the tablespace. */ /** Bit mask of the COMPACT field */ #define DICT_TF_MASK_COMPACT \ - ((~(~0 << DICT_TF_WIDTH_COMPACT)) \ + ((~(~0U << DICT_TF_WIDTH_COMPACT)) \ << DICT_TF_POS_COMPACT) /** Bit mask of the ZIP_SSIZE field */ #define DICT_TF_MASK_ZIP_SSIZE \ - ((~(~0 << DICT_TF_WIDTH_ZIP_SSIZE)) \ + ((~(~0U << DICT_TF_WIDTH_ZIP_SSIZE)) \ << DICT_TF_POS_ZIP_SSIZE) /** Bit mask of the ATOMIC_BLOBS field */ #define DICT_TF_MASK_ATOMIC_BLOBS \ - ((~(~0 << DICT_TF_WIDTH_ATOMIC_BLOBS)) \ + ((~(~0U << DICT_TF_WIDTH_ATOMIC_BLOBS)) \ << DICT_TF_POS_ATOMIC_BLOBS) /** Bit mask of the DATA_DIR field */ #define DICT_TF_MASK_DATA_DIR \ - ((~(~0 << DICT_TF_WIDTH_DATA_DIR)) \ + ((~(~0U << DICT_TF_WIDTH_DATA_DIR)) \ << DICT_TF_POS_DATA_DIR) /** Bit mask of the SHARED_SPACE field */ #define DICT_TF_MASK_SHARED_SPACE \ - ((~(~0 << DICT_TF_WIDTH_SHARED_SPACE)) \ + ((~(~0U << DICT_TF_WIDTH_SHARED_SPACE)) \ << DICT_TF_POS_SHARED_SPACE) /** Return the value of the COMPACT field */ @@ -225,7 +225,7 @@ for unknown bits in order to protect backward incompatibility. */ /* @{ */ /** Total number of bits in table->flags2. */ #define DICT_TF2_BITS 8 -#define DICT_TF2_UNUSED_BIT_MASK (~0 << DICT_TF2_BITS) +#define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS) #define DICT_TF2_BIT_MASK ~DICT_TF2_UNUSED_BIT_MASK /** TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE. */ diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h index abbc7f97d14..ba66b84e9c8 100644 --- a/storage/innobase/include/fsp0types.h +++ b/storage/innobase/include/fsp0types.h @@ -286,31 +286,31 @@ it is for a single client and should be deleted upon startup if it exists. */ /** Bit mask of the POST_ANTELOPE field */ #define FSP_FLAGS_MASK_POST_ANTELOPE \ - ((~(~0 << FSP_FLAGS_WIDTH_POST_ANTELOPE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_POST_ANTELOPE)) \ << FSP_FLAGS_POS_POST_ANTELOPE) /** Bit mask of the ZIP_SSIZE field */ #define FSP_FLAGS_MASK_ZIP_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_ZIP_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_ZIP_SSIZE)) \ << FSP_FLAGS_POS_ZIP_SSIZE) /** Bit mask of the ATOMIC_BLOBS field */ #define FSP_FLAGS_MASK_ATOMIC_BLOBS \ - ((~(~0 << FSP_FLAGS_WIDTH_ATOMIC_BLOBS)) \ + ((~(~0U << FSP_FLAGS_WIDTH_ATOMIC_BLOBS)) \ << FSP_FLAGS_POS_ATOMIC_BLOBS) /** Bit mask of the PAGE_SSIZE field */ #define FSP_FLAGS_MASK_PAGE_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ << FSP_FLAGS_POS_PAGE_SSIZE) /** Bit mask of the DATA_DIR field */ #define FSP_FLAGS_MASK_DATA_DIR \ - ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \ + ((~(~0U << FSP_FLAGS_WIDTH_DATA_DIR)) \ << FSP_FLAGS_POS_DATA_DIR) /** Bit mask of the SHARED field */ #define FSP_FLAGS_MASK_SHARED \ - ((~(~0 << FSP_FLAGS_WIDTH_SHARED)) \ + ((~(~0U << FSP_FLAGS_WIDTH_SHARED)) \ << FSP_FLAGS_POS_SHARED) /** Bit mask of the TEMPORARY field */ #define FSP_FLAGS_MASK_TEMPORARY \ - ((~(~0 << FSP_FLAGS_WIDTH_TEMPORARY)) \ + ((~(~0U << FSP_FLAGS_WIDTH_TEMPORARY)) \ << FSP_FLAGS_POS_TEMPORARY) /** Return the value of the POST_ANTELOPE field */ diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 414de4922d6..ae17303287e 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -2644,6 +2644,7 @@ int mi_repair_parallel(MI_CHECK *param, MI_INFO *info, int error; DBUG_ENTER("mi_repair_parallel"); + memset(&new_data_cache, 0, sizeof(IO_CACHE)); start_records=info->state->records; got_error=1; new_file= -1; diff --git a/testclients/mysql_client_test.c b/testclients/mysql_client_test.c index d4317622faa..4504289701c 100644 --- a/testclients/mysql_client_test.c +++ b/testclients/mysql_client_test.c @@ -20475,10 +20475,10 @@ static void test_bug20821550() int ret_val; ulong max_allowed_packet_value= 8192*2; ulong net_buffer_length_value= 8192*4; - ulong save_max_allowed_packet_value; - ulong save_net_buffer_length_value; - ulong ret_max_allowed_packet_value; - ulong ret_net_buffer_length_value; + ulong save_max_allowed_packet_value= 0; + ulong save_net_buffer_length_value= 0; + ulong ret_max_allowed_packet_value= 0; + ulong ret_net_buffer_length_value= 0; myheader("test_bug20821550");