Remove compiler warnings

- Remove unused variables
- Mark variables unused
- Fix wrong types
- Add no-strict-aliasing to BUILD scripts
This commit is contained in:
Michael Widenius 2018-04-11 02:20:22 +03:00
parent dbbe70e1cf
commit ddc5764303
15 changed files with 25 additions and 24 deletions

View File

@ -140,7 +140,7 @@ elif [ "x$warning_mode" = "xmaintainer" ]; then
debug_extra_cflags="-g3" debug_extra_cflags="-g3"
else else
# Both C and C++ warnings # Both C and C++ warnings
warnings="-Wall -Wextra -Wunused -Wwrite-strings -Wno-uninitialized" warnings="-Wall -Wextra -Wunused -Wwrite-strings -Wno-uninitialized -Wno-strict-aliasing"
# For more warnings, uncomment the following line # For more warnings, uncomment the following line
# warnings="$warnings -Wshadow" # warnings="$warnings -Wshadow"

View File

@ -3036,7 +3036,7 @@ static dberr_t xb_assign_undo_space_start()
byte* page; byte* page;
bool ret; bool ret;
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
ulint space, page_no; ulint space, page_no __attribute__((unused));
if (srv_undo_tablespaces == 0) { if (srv_undo_tablespaces == 0) {
return error; return error;

View File

@ -2615,7 +2615,7 @@ String *Item_func_json_remove::val_str(String *str)
{ {
uint array_counters[JSON_DEPTH_LIMIT]; uint array_counters[JSON_DEPTH_LIMIT];
json_path_with_flags *c_path= paths + n_path; json_path_with_flags *c_path= paths + n_path;
const char *rem_start, *rem_end; const char *rem_start= 0, *rem_end;
const json_path_step_t *lp; const json_path_step_t *lp;
uint n_item= 0; uint n_item= 0;

View File

@ -2456,7 +2456,7 @@ Item *Item_sum_max::copy_or_same(THD* thd)
bool Item_sum_max::add() bool Item_sum_max::add()
{ {
Item *tmp_item; Item * UNINIT_VAR(tmp_item);
DBUG_ENTER("Item_sum_max::add"); DBUG_ENTER("Item_sum_max::add");
DBUG_PRINT("enter", ("this: %p", this)); DBUG_PRINT("enter", ("this: %p", this));
@ -2661,7 +2661,7 @@ void Item_sum_num::reset_field()
void Item_sum_hybrid::reset_field() void Item_sum_hybrid::reset_field()
{ {
Item *tmp_item, *arg0; Item *UNINIT_VAR(tmp_item), *arg0;
DBUG_ENTER("Item_sum_hybrid::reset_field"); DBUG_ENTER("Item_sum_hybrid::reset_field");
arg0= args[0]; arg0= args[0];
@ -3018,7 +3018,7 @@ Item *Item_sum_avg::result_item(THD *thd, Field *field)
void Item_sum_hybrid::update_field() void Item_sum_hybrid::update_field()
{ {
DBUG_ENTER("Item_sum_hybrid::update_field"); DBUG_ENTER("Item_sum_hybrid::update_field");
Item *tmp_item; Item *UNINIT_VAR(tmp_item);
if (unlikely(direct_added)) if (unlikely(direct_added))
{ {
tmp_item= args[0]; tmp_item= args[0];

View File

@ -862,7 +862,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
table_map tables_usable_for_splitting= table_map tables_usable_for_splitting=
spl_opt_info->tables_usable_for_splitting; spl_opt_info->tables_usable_for_splitting;
KEYUSE_EXT *keyuse_ext= &join->ext_keyuses_for_splitting->at(0); KEYUSE_EXT *keyuse_ext= &join->ext_keyuses_for_splitting->at(0);
KEYUSE_EXT *best_key_keyuse_ext_start; KEYUSE_EXT *UNINIT_VAR(best_key_keyuse_ext_start);
TABLE *best_table= 0; TABLE *best_table= 0;
double best_rec_per_key= DBL_MAX; double best_rec_per_key= DBL_MAX;
SplM_plan_info *spl_plan= 0; SplM_plan_info *spl_plan= 0;

View File

@ -1520,7 +1520,7 @@ scan_one_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array,
LEX_CSTRING *tablename, void **out_hton) LEX_CSTRING *tablename, void **out_hton)
{ {
TABLE_LIST tlist; TABLE_LIST tlist;
TABLE *table; TABLE *UNINIT_VAR(table);
bool table_opened= false; bool table_opened= false;
bool table_scanned= false; bool table_scanned= false;
struct gtid_pos_element tmp_entry, *entry; struct gtid_pos_element tmp_entry, *entry;

View File

@ -356,7 +356,7 @@ end:
static void static void
handle_gtid_pos_auto_create_request(THD *thd, void *hton) handle_gtid_pos_auto_create_request(THD *thd, void *hton)
{ {
int err; int UNINIT_VAR(err);
plugin_ref engine= NULL, *auto_engines; plugin_ref engine= NULL, *auto_engines;
rpl_slave_state::gtid_pos_table *entry; rpl_slave_state::gtid_pos_table *entry;
StringBuffer<FN_REFLEN> loc_table_name; StringBuffer<FN_REFLEN> loc_table_name;
@ -6069,7 +6069,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
{ {
int error= 0; int error= 0;
StringBuffer<1024> error_msg; StringBuffer<1024> error_msg;
ulonglong inc_pos; ulonglong inc_pos= 0;
ulonglong event_pos; ulonglong event_pos;
Relay_log_info *rli= &mi->rli; Relay_log_info *rli= &mi->rli;
mysql_mutex_t *log_lock= rli->relay_log.get_log_lock(); mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();

View File

@ -6548,7 +6548,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
Query_arena *arena, backup; Query_arena *arena, backup;
bool result= TRUE; bool result= TRUE;
bool first_outer_loop= TRUE; bool first_outer_loop= TRUE;
Field *field_1, *field_2; Field *field_1;
field_visibility_t field_1_invisible, field_2_invisible; field_visibility_t field_1_invisible, field_2_invisible;
/* /*
Leaf table references to which new natural join columns are added Leaf table references to which new natural join columns are added
@ -6572,6 +6572,8 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
{ {
bool found= FALSE; bool found= FALSE;
const LEX_CSTRING *field_name_1; const LEX_CSTRING *field_name_1;
Field *field_2= 0;
/* true if field_name_1 is a member of using_fields */ /* true if field_name_1 is a member of using_fields */
bool is_using_column_1; bool is_using_column_1;
if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1))) if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1)))

View File

@ -4891,7 +4891,7 @@ end_with_restore_list:
unit->set_limit(select_lex); unit->set_limit(select_lex);
MYSQL_DELETE_START(thd->query()); MYSQL_DELETE_START(thd->query());
Protocol *save_protocol; Protocol * UNINIT_VAR(save_protocol);
bool replaced_protocol= false; bool replaced_protocol= false;
if (!select_lex->item_list.is_empty()) if (!select_lex->item_list.is_empty())

View File

@ -1188,7 +1188,6 @@ buf_madvise_do_dump()
{ {
int ret= 0; int ret= 0;
buf_pool_t* buf_pool; buf_pool_t* buf_pool;
ulint n;
buf_chunk_t* chunk; buf_chunk_t* chunk;
/* mirrors allocation in log_sys_init() */ /* mirrors allocation in log_sys_init() */
@ -1207,7 +1206,7 @@ buf_madvise_do_dump()
buf_pool_mutex_enter_all(); buf_pool_mutex_enter_all();
for (int i= 0; i < srv_buf_pool_instances; i++) for (ulong i= 0; i < srv_buf_pool_instances; i++)
{ {
buf_pool = buf_pool_from_array(i); buf_pool = buf_pool_from_array(i);
chunk = buf_pool->chunks; chunk = buf_pool->chunks;

View File

@ -967,7 +967,7 @@ buf_flush_init_for_writing(
} }
} }
uint32_t checksum; uint32_t checksum= 0;
switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) { switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) {
case SRV_CHECKSUM_ALGORITHM_INNODB: case SRV_CHECKSUM_ALGORITHM_INNODB:

View File

@ -322,7 +322,7 @@ rec_init_offsets_comp_ordinary(
|| dict_table_is_comp(index->table)); || dict_table_is_comp(index->table));
ut_ad(format != REC_LEAF_TEMP_COLUMNS_ADDED ut_ad(format != REC_LEAF_TEMP_COLUMNS_ADDED
|| index->n_fields == rec_offs_n_fields(offsets)); || index->n_fields == rec_offs_n_fields(offsets));
ut_d(ulint n_null); ut_d(ulint n_null= 0);
switch (format) { switch (format) {
case REC_LEAF_TEMP: case REC_LEAF_TEMP:
@ -1447,10 +1447,10 @@ rec_convert_dtuple_to_rec_comp(
byte* end; byte* end;
byte* nulls = temp byte* nulls = temp
? rec - 1 : rec - (REC_N_NEW_EXTRA_BYTES + 1); ? rec - 1 : rec - (REC_N_NEW_EXTRA_BYTES + 1);
byte* lens; byte* UNINIT_VAR(lens);
ulint len; ulint len;
ulint i; ulint i;
ulint n_node_ptr_field; ulint UNINIT_VAR(n_node_ptr_field);
ulint fixed_len; ulint fixed_len;
ulint null_mask = 1; ulint null_mask = 1;
@ -1835,7 +1835,7 @@ rec_copy_prefix_to_buf(
ulint* buf_size) /*!< in/out: buffer size */ ulint* buf_size) /*!< in/out: buffer size */
{ {
const byte* nulls; const byte* nulls;
const byte* lens; const byte* UNINIT_VAR(lens);
ulint i; ulint i;
ulint prefix_len; ulint prefix_len;
ulint null_mask; ulint null_mask;
@ -2129,7 +2129,7 @@ rec_print_comp(
ulint i; ulint i;
for (i = 0; i < rec_offs_n_fields(offsets); i++) { for (i = 0; i < rec_offs_n_fields(offsets); i++) {
const byte* data; const byte* UNINIT_VAR(data);
ulint len; ulint len;
if (rec_offs_nth_default(offsets, i)) { if (rec_offs_nth_default(offsets, i)) {

View File

@ -4177,7 +4177,7 @@ row_search_mvcc(
trx_t* trx = prebuilt->trx; trx_t* trx = prebuilt->trx;
dict_index_t* clust_index; dict_index_t* clust_index;
que_thr_t* thr; que_thr_t* thr;
const rec_t* rec; const rec_t* UNINIT_VAR(rec);
const dtuple_t* vrow = NULL; const dtuple_t* vrow = NULL;
const rec_t* result_rec = NULL; const rec_t* result_rec = NULL;
const rec_t* clust_rec; const rec_t* clust_rec;

View File

@ -3091,7 +3091,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
HA_CREATE_INFO *ha_create_info) HA_CREATE_INFO *ha_create_info)
{ {
int error; int error;
uint create_flags= 0, record_count, i; uint create_flags= 0, record_count= 0, i;
char buff[FN_REFLEN]; char buff[FN_REFLEN];
MARIA_KEYDEF *keydef; MARIA_KEYDEF *keydef;
MARIA_COLUMNDEF *recinfo; MARIA_COLUMNDEF *recinfo;

View File

@ -2811,7 +2811,7 @@ int spider_internal_xa_commit_by_xid(
SPIDER_TRX *trx, SPIDER_TRX *trx,
XID* xid XID* xid
) { ) {
TABLE *table_xa, *table_xa_member; TABLE *table_xa, *table_xa_member= 0;
int error_num; int error_num;
char xa_key[MAX_KEY_LENGTH]; char xa_key[MAX_KEY_LENGTH];
char xa_member_key[MAX_KEY_LENGTH]; char xa_member_key[MAX_KEY_LENGTH];
@ -3046,7 +3046,7 @@ int spider_internal_xa_rollback_by_xid(
SPIDER_TRX *trx, SPIDER_TRX *trx,
XID* xid XID* xid
) { ) {
TABLE *table_xa, *table_xa_member; TABLE *table_xa, *table_xa_member= 0;
int error_num; int error_num;
char xa_key[MAX_KEY_LENGTH]; char xa_key[MAX_KEY_LENGTH];
char xa_member_key[MAX_KEY_LENGTH]; char xa_member_key[MAX_KEY_LENGTH];