Skip to content

Commit 34f1c41

Browse files
author
Davi Arnaut
committed
Bug#12727287: Maintainer mode compilation fails with gcc 4.6 (#trunk)
GCC 4.6 has a new -Wunused-but-set-variable flag, which is enabled by -Wall, that causes GCC to emit a warning whenever a local variable is assigned to, but otherwise unused (aside from its declaration). Since the maintainer mode uses -Wall and -Werror, source code which triggers these warnings will be rejected. That is, these warnings become hard errors. The solution is to fix the code which triggers these specific warnings. In most of the cases, this is a welcome cleanup as code which triggers this warning is probably dead anyway.
1 parent e6843bc commit 34f1c41

File tree

10 files changed

+20
-55
lines changed

10 files changed

+20
-55
lines changed

sql/handler.cc

+8-10
Original file line numberDiff line numberDiff line change
@@ -5278,7 +5278,7 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
52785278
uint *buffer_size, COST_VECT *cost)
52795279
{
52805280
ulong max_buff_entries, elem_size;
5281-
ha_rows rows_in_full_step, rows_in_last_step;
5281+
ha_rows rows_in_last_step;
52825282
uint n_full_steps;
52835283
double index_read_cost;
52845284

@@ -5290,15 +5290,13 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
52905290

52915291
/* Number of iterations we'll make with full buffer */
52925292
n_full_steps= (uint)floor(rows2double(rows) / max_buff_entries);
5293-
5294-
/*
5295-
Get numbers of rows we'll be processing in
5296-
- non-last sweep, with full buffer
5297-
- last iteration, with non-full buffer
5293+
5294+
/*
5295+
Get numbers of rows we'll be processing in last iteration, with
5296+
non-full buffer
52985297
*/
5299-
rows_in_full_step= max_buff_entries;
53005298
rows_in_last_step= rows % max_buff_entries;
5301-
5299+
53025300
/* Adjust buffer size if we expect to use only part of the buffer */
53035301
if (n_full_steps)
53045302
{
@@ -5312,11 +5310,11 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
53125310
(size_t)(1.2*rows_in_last_step) * elem_size +
53135311
h->ref_length + table->key_info[keynr].key_length);
53145312
}
5315-
5313+
53165314
COST_VECT last_step_cost;
53175315
get_sort_and_sweep_cost(table, rows_in_last_step, &last_step_cost);
53185316
cost->add(&last_step_cost);
5319-
5317+
53205318
if (n_full_steps != 0)
53215319
cost->mem_cost= *buffer_size;
53225320
else

sql/item_geofunc.cc

+2-6
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static double distance_points(const Gcalc_heap::Info *a,
661661
static int calc_distance(double *result, Gcalc_heap *collector, uint obj2_si,
662662
Gcalc_function *func, Gcalc_scan_iterator *scan_it)
663663
{
664-
bool above_cur_point, cur_point_edge;
664+
bool cur_point_edge;
665665
const Gcalc_scan_iterator::point *evpos;
666666
const Gcalc_heap::Info *cur_point, *dist_point;
667667
Gcalc_scan_events ev;
@@ -670,7 +670,6 @@ static int calc_distance(double *result, Gcalc_heap *collector, uint obj2_si,
670670

671671
DBUG_ENTER("calc_distance");
672672

673-
above_cur_point= false;
674673
distance= DBL_MAX;
675674

676675
while (scan_it->more_points())
@@ -781,7 +780,6 @@ static int calc_distance(double *result, Gcalc_heap *collector, uint obj2_si,
781780

782781
int Item_func_spatial_rel::func_touches()
783782
{
784-
bool above_cur_point;
785783
double x1, x2, y1, y2, ex, ey;
786784
double distance, area;
787785
int result= 0;
@@ -836,7 +834,6 @@ int Item_func_spatial_rel::func_touches()
836834
scan_it.reset();
837835
scan_it.init(&collector);
838836

839-
above_cur_point= false;
840837
distance= DBL_MAX;
841838

842839
while (scan_it.more_trapezoids())
@@ -1677,7 +1674,7 @@ longlong Item_func_srid::val_int()
16771674

16781675
double Item_func_distance::val_real()
16791676
{
1680-
bool above_cur_point, cur_point_edge;
1677+
bool cur_point_edge;
16811678
const Gcalc_scan_iterator::point *evpos;
16821679
const Gcalc_heap::Info *cur_point, *dist_point;
16831680
Gcalc_scan_events ev;
@@ -1724,7 +1721,6 @@ double Item_func_distance::val_real()
17241721
collector.prepare_operation();
17251722
scan_it.init(&collector);
17261723

1727-
above_cur_point= false;
17281724
distance= DBL_MAX;
17291725
while (scan_it.more_points())
17301726
{

sql/partition_info.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,11 @@ char *partition_info::find_duplicate_name()
636636
HASH partition_names;
637637
uint max_names;
638638
const uchar *curr_name= NULL;
639-
size_t length;
640639
List_iterator<partition_element> parts_it(partitions);
641-
partition_element *p_elem;
640+
partition_element *p_elem;
642641

643642
DBUG_ENTER("partition_info::find_duplicate_name");
644-
643+
645644
/*
646645
TODO: If table->s->ha_part_data->partition_name_hash.elements is > 0,
647646
then we could just return NULL, but that has not been verified.
@@ -661,7 +660,6 @@ char *partition_info::find_duplicate_name()
661660
while ((p_elem= (parts_it++)))
662661
{
663662
curr_name= (const uchar*) p_elem->partition_name;
664-
length= strlen(p_elem->partition_name);
665663
if (my_hash_insert(&partition_names, curr_name))
666664
goto error;
667665

@@ -676,7 +674,7 @@ char *partition_info::find_duplicate_name()
676674
goto error;
677675
}
678676
}
679-
}
677+
}
680678
my_hash_free(&partition_names);
681679
DBUG_RETURN(NULL);
682680
error:

sql/rpl_info_file.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,9 @@ bool init_dynarray_intvar_from_file(char *buffer, size_t size,
482482
(decimal size + space) - 1 + `\n' + '\0'
483483
*/
484484
size_t max_size= (1 + num_items) * (sizeof(long) * 3 + 1) + 1;
485-
buf_act= (char*) my_malloc(max_size, MYF(MY_WME));
486-
buffer_act= &buf_act;
485+
if (! (buf_act= (char*) my_malloc(max_size, MYF(MY_WME))))
486+
DBUG_RETURN(TRUE);
487+
*buffer_act= buf_act;
487488
memcpy(buf_act, buf, read_size);
488489
snd_size= my_b_gets(f, buf_act + read_size, max_size - read_size);
489490
if (snd_size == 0 ||

sql/sql_load.cc

+1-4
Original file line numberDiff line numberDiff line change
@@ -1122,12 +1122,9 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
11221122
List_iterator_fast<Item> it(fields_vars);
11231123
Item *item;
11241124
TABLE *table= table_list->table;
1125-
bool no_trans_update_stmt;
11261125
const CHARSET_INFO *cs= read_info.read_charset;
11271126
DBUG_ENTER("read_xml_field");
1128-
1129-
no_trans_update_stmt= !table->file->has_transactions();
1130-
1127+
11311128
for ( ; ; it.rewind())
11321129
{
11331130
if (thd->killed)

sql/sql_select.cc

+2-11
Original file line numberDiff line numberDiff line change
@@ -3955,7 +3955,7 @@ bool convert_subquery_to_semijoin(JOIN *parent_join,
39553955
st_select_lex *subq_lex= subq_pred->unit->first_select();
39563956
nested_join->join_list.empty();
39573957
List_iterator_fast<TABLE_LIST> li(subq_lex->top_join_list);
3958-
TABLE_LIST *tl, *last_leaf;
3958+
TABLE_LIST *tl;
39593959
while ((tl= li++))
39603960
{
39613961
tl->embedding= sj_nest;
@@ -3973,7 +3973,6 @@ bool convert_subquery_to_semijoin(JOIN *parent_join,
39733973
for (tl= parent_lex->leaf_tables; tl->next_leaf; tl= tl->next_leaf)
39743974
{}
39753975
tl->next_leaf= subq_lex->leaf_tables;
3976-
last_leaf= tl;
39773976

39783977
/*
39793978
Same as above for next_local chain
@@ -4258,7 +4257,6 @@ bool JOIN::flatten_subqueries()
42584257
DBUG_RETURN(TRUE);
42594258
}
42604259
skip_conversion:
4261-
bool converted= FALSE;
42624260
/*
42634261
3. Finalize the subqueries that we did not convert,
42644262
ie. perform IN->EXISTS rewrite.
@@ -4272,7 +4270,6 @@ bool JOIN::flatten_subqueries()
42724270

42734271
SELECT_LEX *save_select_lex= thd->lex->current_select;
42744272
thd->lex->current_select= (*subq)->unit->first_select();
4275-
converted= TRUE;
42764273

42774274
res= (*subq)->select_transformer(child_join);
42784275

@@ -11822,8 +11819,6 @@ static bool
1182211819
make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
1182311820
{
1182411821
const bool statistics= test(!(join->select_options & SELECT_DESCRIBE));
11825-
uint first_sjm_table= MAX_TABLES;
11826-
uint last_sjm_table= MAX_TABLES;
1182711822

1182811823
/* First table sorted if ORDER or GROUP BY was specified */
1182911824
bool sorted= (join->order || join->group_list);
@@ -11857,8 +11852,6 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
1185711852
if (sj_is_materialize_strategy(join->best_positions[i].sj_strategy))
1185811853
{
1185911854
/* This is a start of semi-join nest */
11860-
first_sjm_table= i;
11861-
last_sjm_table= i + join->best_positions[i].n_sj_tables;
1186211855
if (i == join->const_tables)
1186311856
join->first_select= sub_select_sjm;
1186411857
else
@@ -16841,7 +16834,7 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
1684116834
bool using_unique_constraint=FALSE;
1684216835
bool use_packed_rows= FALSE;
1684316836
Field *field, *key_field;
16844-
uint blob_count, null_pack_length, null_count;
16837+
uint null_pack_length, null_count;
1684516838
uchar *null_flags;
1684616839
uchar *pos;
1684716840
DBUG_ENTER("create_duplicate_weedout_tmp_table");
@@ -16922,8 +16915,6 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
1692216915
share->keys_for_keyread.init();
1692316916
share->keys_in_use.init();
1692416917

16925-
blob_count= 0;
16926-
1692716918
/* Create the field */
1692816919
{
1692916920
/*

storage/innobase/trx/trx0purge.c

-4
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ trx_purge_add_update_undo_to_history(
216216
trx_rseg_t* rseg;
217217
trx_rsegf_t* rseg_header;
218218
trx_ulogf_t* undo_header;
219-
trx_upagef_t* page_header;
220219

221220
undo = trx->update_undo;
222221
rseg = undo->rseg;
@@ -226,7 +225,6 @@ trx_purge_add_update_undo_to_history(
226225
mtr);
227226

228227
undo_header = undo_page + undo->hdr_offset;
229-
page_header = undo_page + TRX_UNDO_PAGE_HDR;
230228

231229
if (undo->state != TRX_UNDO_CACHED) {
232230
ulint hist_size;
@@ -559,7 +557,6 @@ trx_purge_rseg_get_next_history_log(
559557
const void* ptr;
560558
page_t* undo_page;
561559
trx_ulogf_t* log_hdr;
562-
trx_usegf_t* seg_hdr;
563560
fil_addr_t prev_log_addr;
564561
trx_id_t trx_no;
565562
ibool del_marks;
@@ -580,7 +577,6 @@ trx_purge_rseg_get_next_history_log(
580577
rseg->space, rseg->zip_size, rseg->last_page_no, &mtr);
581578

582579
log_hdr = undo_page + rseg->last_offset;
583-
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
584580

585581
/* Increase the purge page count by one for every handled log */
586582

storage/innobase/trx/trx0rec.c

-2
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,6 @@ trx_undo_prev_version_build(
14681468
table_id_t table_id;
14691469
trx_id_t trx_id;
14701470
roll_ptr_t roll_ptr;
1471-
roll_ptr_t old_roll_ptr;
14721471
upd_t* update;
14731472
byte* ptr;
14741473
ulint info_bits;
@@ -1486,7 +1485,6 @@ trx_undo_prev_version_build(
14861485
ut_a(dict_index_is_clust(index));
14871486

14881487
roll_ptr = row_get_rec_roll_ptr(rec, index, offsets);
1489-
old_roll_ptr = roll_ptr;
14901488

14911489
*old_vers = NULL;
14921490

storage/perfschema/pfs_instr.cc

-10
Original file line numberDiff line numberDiff line change
@@ -1411,12 +1411,10 @@ void aggregate_all_event_names(PFS_single_stat *from_array,
14111411
PFS_single_stat *from;
14121412
PFS_single_stat *from_last;
14131413
PFS_single_stat *to;
1414-
PFS_single_stat *to_last;
14151414

14161415
from= from_array;
14171416
from_last= from_array + wait_class_max;
14181417
to= to_array;
1419-
to_last= to_array + wait_class_max;
14201418

14211419
for ( ; from < from_last ; from++, to++)
14221420
{
@@ -1435,16 +1433,12 @@ void aggregate_all_event_names(PFS_single_stat *from_array,
14351433
PFS_single_stat *from;
14361434
PFS_single_stat *from_last;
14371435
PFS_single_stat *to_1;
1438-
PFS_single_stat *to_1_last;
14391436
PFS_single_stat *to_2;
1440-
PFS_single_stat *to_2_last;
14411437

14421438
from= from_array;
14431439
from_last= from_array + wait_class_max;
14441440
to_1= to_array_1;
1445-
to_1_last= to_array_1 + wait_class_max;
14461441
to_2= to_array_2;
1447-
to_2_last= to_array_2 + wait_class_max;
14481442

14491443
for ( ; from < from_last ; from++, to_1++, to_2++)
14501444
{
@@ -1463,12 +1457,10 @@ void aggregate_all_stages(PFS_stage_stat *from_array,
14631457
PFS_stage_stat *from;
14641458
PFS_stage_stat *from_last;
14651459
PFS_stage_stat *to;
1466-
PFS_stage_stat *to_last;
14671460

14681461
from= from_array;
14691462
from_last= from_array + stage_class_max;
14701463
to= to_array;
1471-
to_last= to_array + stage_class_max;
14721464

14731465
for ( ; from < from_last ; from++, to++)
14741466
{
@@ -1486,12 +1478,10 @@ void aggregate_all_statements(PFS_statement_stat *from_array,
14861478
PFS_statement_stat *from;
14871479
PFS_statement_stat *from_last;
14881480
PFS_statement_stat *to;
1489-
PFS_statement_stat *to_last;
14901481

14911482
from= from_array;
14921483
from_last= from_array + statement_class_max;
14931484
to= to_array;
1494-
to_last= to_array + statement_class_max;
14951485

14961486
for ( ; from < from_last ; from++, to++)
14971487
{

storage/perfschema/unittest/pfs_instr_class-t.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ void test_no_registration()
8080
file_key= register_file_class("FOO", 3, 0);
8181
ok(file_key == 0, "no file registered");
8282

83+
#ifdef LATER
8384
PFS_thread fake_thread;
8485
fake_thread.m_table_share_hash_pins= NULL;
8586

86-
#ifdef LATER
8787
table= find_or_create_table_share(& fake_thread, false, "foo_db", 6, "foo_table", 9);
8888
ok(table == NULL, "not created");
8989
table= find_or_create_table_share(& fake_thread, false, "bar_db", 6, "bar_table", 9);

0 commit comments

Comments
 (0)