-Wunused-but-set-variable -Warray-bounds warnings

Bug #1616753 reported by Laurynas Biveinis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Fix Released
Low
Laurynas Biveinis
5.6
Invalid
Undecided
Unassigned
5.7
Invalid
Undecided
Unassigned

Bug Description

5.5 trunk:

/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/ubuntu-precise-32bit/strings/ctype-ucs2.c: In function ‘my_fill_utf32’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/ubuntu-precise-32bit/strings/ctype-ucs2.c:2321:8: warning: variable ‘buflen’ set but not used [-Wunused-but-set-variable]

/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/ubuntu-precise-32bit/sql/filesort.cc: In function ‘void make_sortkey(SORTPARAM*, uchar*, uchar*)’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/ubuntu-precise-32bit/sql/filesort.cc:872:16: warning: variable ‘tmp_length’ set but not used [-Wunused-but-set-variable]

/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/ubuntu-precise-32bit/sql/slave.cc: In function ‘int terminate_slave_thread(THD*, mysql_mutex_t*, mysql_cond_t*, volatile uint*, bool)’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/ubuntu-precise-32bit/sql/slave.cc:665:9: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]

For fix, partially backport

commit bccdbcba25ec4fead4ae630efd8fb2885e1aaa30
Author: Tor Didriksen <email address hidden>
Date: Fri Feb 13 10:02:59 2015 +0100

    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

Tags: upstream
description: updated
tags: added: upstream
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :
Download full text (4.8 KiB)

The same backport also fixes

/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c: In function ‘do_div_mod’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:2145:55: warning: array subscript is below array bounds [-Warray-bounds]
   for (i= (prec2 - 1) % DIG_PER_DEC1; *buf2 < powers10[i--]; prec2--) ;
                                                       ^
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:2160:52: warning: array subscript is below array bounds [-Warray-bounds]
   for (i=(prec1-1) % DIG_PER_DEC1; *buf1 < powers10[i--]; prec1--) ;
                                                    ^
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:2145:55: warning: array subscript is below array bounds [-Warray-bounds]
   for (i= (prec2 - 1) % DIG_PER_DEC1; *buf2 < powers10[i--]; prec2--) ;
                                                       ^
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:2160:52: warning: array subscript is below array bounds [-Warray-bounds]
   for (i=(prec1-1) % DIG_PER_DEC1; *buf1 < powers10[i--]; prec1--) ;

/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c: In function ‘decimal_actual_fraction’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:300:26: warning: array subscript is above array bounds [-Warray-bounds]
          *buf0 % powers10[i++] == 0;
                          ^
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:300:26: warning: array subscript is above array bounds [-Warray-bounds]
[ 12%] Building C object strings/CMakeFiles/strings.dir/longlong2str.c.o
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c: In function ‘decimal2string’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:264:56: warning: array subscript is below array bounds [-Warray-bounds]
     for (i= (intg - 1) % DIG_PER_DEC1; *buf0 < powers10[i--]; intg--) ;
                                                        ^
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:264:56: warning: array subscript is below array bounds [-Warray-bounds]
[ 12%] Building C object strings/CMakeFiles/strings.dir/my_strtoll10.c.o
[ 12%] Building C object strings/CMakeFiles/strings.dir/my_vsnprintf.c.o
[ 12%] Building C object strings/CMakeFiles/strings.dir/str2int.c.o
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c: In function ‘decimal2bin’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/release/Host/debian-jessie-64bit/strings/decimal.c:264:56: warning: array subscript is below array bounds [-Warray-bounds]
     for (i= (intg - 1) % DIG_PER_DEC1; *buf0 < powers10[i--]; intg--) ;q
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/re...

Read more...

summary: - -Wunused-but-set-variable warnings
+ -Wunused-but-set-variable -Warray-bounds warnings
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-3527

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.