Skip to content

Commit bccdbcb

Browse files
author
Tor Didriksen
committed
Bug#20458574 FIX ALL THE ARRAY BOUNDS WARNINGS
Remove compiler warnings when building in optimized mode: In strings/decimal.c fix numerous warnings of the type: array subscript is below array bounds [-Werror=array-bounds] This part of the patch is based on a patch from https://github.com/webscalesql/webscalesql-5.6 That patch added some bounds-checks for loops, and worked for gcc4.8.3 but not for gcc 4.9.1 so it was re-written to unroll the loops instead. In other source files, fix numerous warnings of the type: variable XX set but not used [-Werror=unused-but-set-variable] variable XX may be used uninitialized in this function [-Werror=maybe-uninitialized] These were variables used only for debugging purposes, or variables not proven to be set by all execution paths. Compiled with gcc 4.7.2 4.8.3 4.9.1 in optimized mode, with -Wall -Werror
1 parent db76d71 commit bccdbcb

File tree

19 files changed

+139
-53
lines changed

19 files changed

+139
-53
lines changed

client/mysqldump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -1907,7 +1907,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
19071907
const char *str_create)
19081908
{
19091909
uint i;
1910-
my_bool body_found= 0;
1910+
my_bool body_found __attribute__((unused)) = 0;
19111911
char *create_stmt_ptr= NULL;
19121912
ulong create_stmt_len= 0;
19131913
MYSQL_FIELD *field;

sql/filesort.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -1020,7 +1020,7 @@ void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos)
10201020
if (sort_field->need_strxnfrm)
10211021
{
10221022
char *from=(char*) res->ptr();
1023-
uint tmp_length;
1023+
uint tmp_length __attribute__((unused));
10241024
if ((uchar*) from == to)
10251025
{
10261026
DBUG_ASSERT(sort_field->length >= length);

sql/ha_partition.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -234,7 +234,7 @@ static bool check_partition_column_order(List<Create_field> *create_list,
234234

235235
Field **f_ptr;
236236
List_iterator_fast<Create_field> new_field_it;
237-
Create_field *new_field;
237+
Create_field *new_field= NULL;
238238
new_field_it.init(*create_list);
239239

240240
for (f_ptr= field_arary ; *f_ptr; f_ptr++)

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -6271,7 +6271,7 @@ int DsMrr_impl::dsmrr_next(char **range_info)
62716271
ha_rows DsMrr_impl::dsmrr_info(uint keyno, uint n_ranges, uint rows,
62726272
uint *bufsz, uint *flags, Cost_estimate *cost)
62736273
{
6274-
ha_rows res;
6274+
ha_rows res __attribute__((unused));
62756275
uint def_flags= *flags;
62766276
uint def_bufsz= *bufsz;
62776277

sql/hostname.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -413,7 +413,7 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage,
413413
{
414414
const struct sockaddr *ip= (const sockaddr *) ip_storage;
415415
int err_code;
416-
bool err_status;
416+
bool err_status __attribute__((unused));
417417
Host_errors errors;
418418

419419
DBUG_ENTER("ip_to_hostname");

sql/log_event.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,7 @@ Slave_worker *Log_event::get_slave_worker(Relay_log_info *rli)
27332733
{
27342734
if (!rli->curr_group_seen_gtid && !rli->curr_group_seen_begin)
27352735
{
2736-
ulong gaq_idx;
2736+
ulong gaq_idx __attribute__((unused));
27372737
rli->mts_groups_assigned++;
27382738

27392739
rli->curr_group_isolated= FALSE;

sql/mdl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -1930,7 +1930,7 @@ MDL_context::find_ticket(MDL_request *mdl_request,
19301930
bool
19311931
MDL_context::try_acquire_lock(MDL_request *mdl_request)
19321932
{
1933-
MDL_ticket *ticket;
1933+
MDL_ticket *ticket= NULL;
19341934

19351935
if (try_acquire_lock_impl(mdl_request, &ticket))
19361936
return TRUE;
@@ -2184,7 +2184,7 @@ bool
21842184
MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout)
21852185
{
21862186
MDL_lock *lock;
2187-
MDL_ticket *ticket;
2187+
MDL_ticket *ticket= NULL;
21882188
struct timespec abs_timeout;
21892189
MDL_wait::enum_wait_status wait_status;
21902190
/* Do some work outside the critical section. */

sql/rpl_master.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
862862
String* packet = &thd->packet;
863863
time_t last_event_sent_ts= time(0);
864864
bool time_for_hb_event= false;
865-
int error;
865+
int error= 0;
866866
const char *errmsg = "Unknown error";
867867
char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message()
868868
NET* net = &thd->net;

sql/rpl_rli_pdb.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
116
#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */
217
#include "sql_priv.h"
318
#include "unireg.h"
@@ -1369,7 +1384,7 @@ ulong Slave_committed_queue::move_queue_head(DYNAMIC_ARRAY *ws)
13691384
Slave_worker *w_i;
13701385
Slave_job_group *ptr_g, g;
13711386
char grl_name[FN_REFLEN];
1372-
ulong ind;
1387+
ulong ind __attribute__((unused));
13731388

13741389
#ifndef DBUG_OFF
13751390
if (DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0) &&

sql/rpl_slave.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ terminate_slave_thread(THD *thd,
12331233

12341234
while (*slave_running) // Should always be true
12351235
{
1236-
int error;
1236+
int error __attribute__((unused));
12371237
DBUG_PRINT("loop", ("killing slave thread"));
12381238

12391239
mysql_mutex_lock(&thd->LOCK_thd_data);

0 commit comments

Comments
 (0)