[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2721)
#At lp:maria 2721 knielsen@knielsen-hq.org 2009-08-27 Fix most Compiler warnings seen in buildbot. Also add suppressions for a few warnings that cannot be meaningfully fixed by MariaDB developers. Changes for XtraDB, PBXT, and YaSSL also submitted upstream. added: support-files/ccfilter modified: client/mysqlbinlog.cc config/ac-macros/misc.m4 extra/yassl/include/yassl_int.hpp extra/yassl/src/handshake.cpp extra/yassl/src/yassl_imp.cpp extra/yassl/src/yassl_int.cpp extra/yassl/taocrypt/include/modes.hpp extra/yassl/taocrypt/src/asn.cpp mysys/my_compress.c sql/mysqld.cc sql/strfunc.cc storage/pbxt/src/datadic_xt.cc storage/pbxt/src/discover_xt.cc storage/xtradb/fil/fil0fil.c storage/xtradb/mtr/mtr0mtr.c storage/xtradb/srv/srv0srv.c storage/xtradb/srv/srv0start.c strings/decimal.c support-files/compiler_warnings.supp per-file messages: client/mysqlbinlog.cc Fix compiler warnings. config/ac-macros/misc.m4 Fix wrong naming, autoconfig requires _cv_ in cached names. extra/yassl/include/yassl_int.hpp Fix compiler warnings. extra/yassl/src/handshake.cpp Fix compiler warnings. extra/yassl/src/yassl_imp.cpp Fix compiler warnings. extra/yassl/src/yassl_int.cpp Fix compiler warnings. extra/yassl/taocrypt/include/modes.hpp Fix compiler warnings. extra/yassl/taocrypt/src/asn.cpp Fix compiler warnings. mysys/my_compress.c Fix compiler warnings. sql/mysqld.cc Fix compiler warnings. sql/strfunc.cc Fix compiler warnings. storage/pbxt/src/datadic_xt.cc Fix compiler warnings. storage/pbxt/src/discover_xt.cc Fix compiler warnings. storage/xtradb/fil/fil0fil.c Fix compiler warnings. storage/xtradb/mtr/mtr0mtr.c Fix compiler warnings. storage/xtradb/srv/srv0srv.c Fix compiler warnings. storage/xtradb/srv/srv0start.c Fix compiler warnings. strings/decimal.c Fix compiler warnings. support-files/ccfilter Add helper for suppressing compiler warnings in local developer source tree. Allows to check for not introducing new warnings into Buildbot without having to actually run the build through Buildbot. support-files/compiler_warnings.supp Suppress a few warnings that cannot be meaningfully fixed in source code. === modified file 'client/mysqlbinlog.cc' --- a/client/mysqlbinlog.cc 2009-02-13 16:41:47 +0000 +++ b/client/mysqlbinlog.cc 2009-08-27 09:48:29 +0000 @@ -689,8 +689,8 @@ Exit_status process_event(PRINT_EVENT_IN Format events are not concerned by --offset and such, we always need to read them to be able to process the wanted events. */ - if ((rec_count >= offset) && - ((my_time_t)(ev->when) >= start_datetime) || + if (((rec_count >= offset) && + ((my_time_t)(ev->when) >= start_datetime)) || (ev_type == FORMAT_DESCRIPTION_EVENT)) { if (ev_type != FORMAT_DESCRIPTION_EVENT) === modified file 'config/ac-macros/misc.m4' --- a/config/ac-macros/misc.m4 2008-02-26 17:38:43 +0000 +++ b/config/ac-macros/misc.m4 2009-08-27 09:48:29 +0000 @@ -594,15 +594,15 @@ dnl ------------------------------------ dnl MYSQL_NEEDS_MYSYS_NEW AC_DEFUN([MYSQL_NEEDS_MYSYS_NEW], -[AC_CACHE_CHECK([needs mysys_new helpers], mysql_use_mysys_new, +[AC_CACHE_CHECK([needs mysys_new helpers], mysql_cv_use_mysys_new, [ AC_LANG_PUSH(C++) AC_TRY_LINK([], [ class A { public: int b; }; A *a=new A; a->b=10; delete a; -], mysql_use_mysys_new=no, mysql_use_mysys_new=yes) +], mysql_cv_use_mysys_new=no, mysql_cv_use_mysys_new=yes) AC_LANG_POP(C++) ]) -if test "$mysql_use_mysys_new" = "yes" +if test "$mysql_cv_use_mysys_new" = "yes" then AC_DEFINE([USE_MYSYS_NEW], [1], [Needs to use mysys_new helpers]) fi === modified file 'extra/yassl/include/yassl_int.hpp' --- a/extra/yassl/include/yassl_int.hpp 2008-11-18 16:45:44 +0000 +++ b/extra/yassl/include/yassl_int.hpp 2009-08-27 09:48:29 +0000 @@ -441,7 +441,7 @@ public: const Ciphers& GetCiphers() const; const DH_Parms& GetDH_Parms() const; const Stats& GetStats() const; - const VerifyCallback getVerifyCallback() const; + VerifyCallback getVerifyCallback() const; pem_password_cb GetPasswordCb() const; void* GetUserData() const; bool GetSessionCacheOff() const; === modified file 'extra/yassl/src/handshake.cpp' --- a/extra/yassl/src/handshake.cpp 2008-04-28 16:24:05 +0000 +++ b/extra/yassl/src/handshake.cpp 2009-08-27 09:48:29 +0000 @@ -789,7 +789,7 @@ void processReply(SSL& ssl) { if (ssl.GetError()) return; - if (DoProcessReply(ssl)) + if (DoProcessReply(ssl)) { // didn't complete process if (!ssl.getSocket().IsNonBlocking()) { // keep trying now, blocking ok @@ -799,6 +799,7 @@ void processReply(SSL& ssl) else // user will have try again later, non blocking ssl.SetError(YasslError(SSL_ERROR_WANT_READ)); + } } @@ -872,11 +873,12 @@ void sendServerKeyExchange(SSL& ssl, Buf // send change cipher void sendChangeCipher(SSL& ssl, BufferOutput buffer) { - if (ssl.getSecurity().get_parms().entity_ == server_end) + if (ssl.getSecurity().get_parms().entity_ == server_end) { if (ssl.getSecurity().get_resuming()) ssl.verifyState(clientKeyExchangeComplete); else ssl.verifyState(clientFinishedComplete); + } if (ssl.GetError()) return; ChangeCipherSpec ccs; === modified file 'extra/yassl/src/yassl_imp.cpp' --- a/extra/yassl/src/yassl_imp.cpp 2009-02-13 16:41:47 +0000 +++ b/extra/yassl/src/yassl_imp.cpp 2009-08-27 09:48:29 +0000 @@ -1304,7 +1304,7 @@ void ServerHello::Process(input_buffer&, else ssl.useSecurity().use_connection().sessionID_Set_ = false; - if (ssl.getSecurity().get_resuming()) + if (ssl.getSecurity().get_resuming()) { if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(), ID_LEN) == 0) { ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret()); @@ -1319,6 +1319,7 @@ void ServerHello::Process(input_buffer&, ssl.useSecurity().set_resuming(false); ssl.useLog().Trace("server denied resumption"); } + } if (ssl.CompressionOn() && !compression_method_) ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request === modified file 'extra/yassl/src/yassl_int.cpp' --- a/extra/yassl/src/yassl_int.cpp 2009-02-13 16:41:47 +0000 +++ b/extra/yassl/src/yassl_int.cpp 2009-08-27 09:48:29 +0000 @@ -1833,7 +1833,7 @@ SSL_CTX::GetCA_List() const } -const VerifyCallback SSL_CTX::getVerifyCallback() const +VerifyCallback SSL_CTX::getVerifyCallback() const { return verifyCallback_; } === modified file 'extra/yassl/taocrypt/include/modes.hpp' --- a/extra/yassl/taocrypt/include/modes.hpp 2007-03-23 12:43:09 +0000 +++ b/extra/yassl/taocrypt/include/modes.hpp 2009-08-27 09:48:29 +0000 @@ -95,11 +95,12 @@ inline void Mode_BASE::Process(byte* out { if (mode_ == ECB) ECB_Process(out, in, sz); - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) CBC_Encrypt(out, in, sz); else CBC_Decrypt(out, in, sz); + } } === modified file 'extra/yassl/taocrypt/src/asn.cpp' --- a/extra/yassl/taocrypt/src/asn.cpp 2009-02-13 16:41:47 +0000 +++ b/extra/yassl/taocrypt/src/asn.cpp 2009-08-27 09:48:29 +0000 @@ -780,11 +780,12 @@ void CertDecoder::GetDate(DateType dt) memcpy(date, source_.get_current(), length); source_.advance(length); - if (!ValidateDate(date, b, dt) && verify_) + if (!ValidateDate(date, b, dt) && verify_) { if (dt == BEFORE) source_.SetError(BEFORE_DATE_E); else source_.SetError(AFTER_DATE_E); + } // save for later use if (dt == BEFORE) { @@ -1061,7 +1062,7 @@ word32 DecodeDSA_Signature(byte* decoded return 0; } word32 rLen = GetLength(source); - if (rLen != 20) + if (rLen != 20) { if (rLen == 21) { // zero at front, eat source.next(); --rLen; @@ -1074,6 +1075,7 @@ word32 DecodeDSA_Signature(byte* decoded source.SetError(DSA_SZ_E); return 0; } + } memcpy(decoded, source.get_buffer() + source.get_index(), rLen); source.advance(rLen); @@ -1083,7 +1085,7 @@ word32 DecodeDSA_Signature(byte* decoded return 0; } word32 sLen = GetLength(source); - if (sLen != 20) + if (sLen != 20) { if (sLen == 21) { source.next(); // zero at front, eat --sLen; @@ -1096,6 +1098,7 @@ word32 DecodeDSA_Signature(byte* decoded source.SetError(DSA_SZ_E); return 0; } + } memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen); source.advance(sLen); === modified file 'mysys/my_compress.c' --- a/mysys/my_compress.c 2009-05-22 12:38:50 +0000 +++ b/mysys/my_compress.c 2009-08-27 09:48:29 +0000 @@ -81,12 +81,13 @@ my_bool my_compress(uchar *packet, size_ This fix is safe, since such memory is only used internally by zlib, so we will not hide any bugs in mysql this way. */ -void *my_az_allocator(void *dummy, unsigned int items, unsigned int size) +void *my_az_allocator(void *dummy __attribute__((unused)), unsigned int items, + unsigned int size) { return my_malloc((size_t)items*(size_t)size, IF_VALGRIND(MY_ZEROFILL, MYF(0))); } -void my_az_free(void *dummy, void *address) +void my_az_free(void *dummy __attribute__((unused)), void *address) { my_free(address, MYF(MY_ALLOW_ZERO_PTR)); } === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2009-05-19 09:28:05 +0000 +++ b/sql/mysqld.cc 2009-08-27 09:48:29 +0000 @@ -1002,6 +1002,7 @@ static void close_connections(void) } +#ifdef HAVE_CLOSE_SERVER_SOCK static void close_socket(my_socket sock, const char *info) { DBUG_ENTER("close_socket"); @@ -1021,6 +1022,7 @@ static void close_socket(my_socket sock, } DBUG_VOID_RETURN; } +#endif static void close_server_sock() === modified file 'sql/strfunc.cc' --- a/sql/strfunc.cc 2009-04-25 10:05:32 +0000 +++ b/sql/strfunc.cc 2009-08-27 09:48:29 +0000 @@ -148,7 +148,7 @@ static uint parse_name(TYPELIB *lib, con } } else - for (; pos != end && *pos != '=' && *pos !=',' ; pos++); + for (; pos != end && *pos != '=' && *pos !=',' ; pos++) {} uint var_len= (uint) (pos - start); /* Determine which flag it is */ === modified file 'storage/pbxt/src/datadic_xt.cc' --- a/storage/pbxt/src/datadic_xt.cc 2009-03-26 12:18:01 +0000 +++ b/storage/pbxt/src/datadic_xt.cc 2009-08-27 09:48:29 +0000 @@ -2871,5 +2871,5 @@ xtBool XTDDTable::checkCanDrop() { /* no refs or references only itself */ return (dt_trefs == NULL) || - (dt_trefs->tr_next == NULL) && (dt_trefs->tr_fkey->co_table == this); + ((dt_trefs->tr_next == NULL) && (dt_trefs->tr_fkey->co_table == this)); } === modified file 'storage/pbxt/src/discover_xt.cc' --- a/storage/pbxt/src/discover_xt.cc 2009-03-26 12:18:01 +0000 +++ b/storage/pbxt/src/discover_xt.cc 2009-08-27 09:48:29 +0000 @@ -493,8 +493,8 @@ mysql_prepare_create_table(THD *thd, HA_ } /* Don't pack rows in old tables if the user has requested this */ if ((sql_field->flags & BLOB_FLAG) || - sql_field->sql_type == MYSQL_TYPE_VARCHAR && - create_info->row_type != ROW_TYPE_FIXED) + (sql_field->sql_type == MYSQL_TYPE_VARCHAR && + create_info->row_type != ROW_TYPE_FIXED)) (*db_options)|= HA_OPTION_PACK_RECORD; it2.rewind(); } @@ -963,7 +963,7 @@ mysql_prepare_create_table(THD *thd, HA_ sql_field->sql_type == MYSQL_TYPE_VARCHAR || sql_field->pack_flag & FIELDFLAG_BLOB))) { - if (column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB) || + if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) || sql_field->sql_type == MYSQL_TYPE_VARCHAR) key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; else === modified file 'storage/xtradb/fil/fil0fil.c' --- a/storage/xtradb/fil/fil0fil.c 2009-06-25 01:43:25 +0000 +++ b/storage/xtradb/fil/fil0fil.c 2009-08-27 09:48:29 +0000 @@ -45,7 +45,9 @@ Created 10/25/1995 Heikki Tuuri #include "trx0trx.h" #include "trx0sys.h" #include "pars0pars.h" +#include "row0row.h" #include "row0mysql.h" +#include "que0que.h" /* @@ -3134,7 +3136,7 @@ skip_info: rec_offs_init(offsets_); - fprintf(stderr, "InnoDB: Progress in %:"); + fprintf(stderr, "%s", "InnoDB: Progress in %:"); for (offset = 0; offset < size_bytes; offset += UNIV_PAGE_SIZE) { success = os_file_read(file, page, === modified file 'storage/xtradb/mtr/mtr0mtr.c' --- a/storage/xtradb/mtr/mtr0mtr.c 2009-06-25 01:43:25 +0000 +++ b/storage/xtradb/mtr/mtr0mtr.c 2009-08-27 09:48:29 +0000 @@ -32,6 +32,7 @@ Created 11/26/1995 Heikki Tuuri #include "page0types.h" #include "mtr0log.h" #include "log0log.h" +#include "buf0flu.h" /********************************************************************* Releases the item in the slot given. */ === modified file 'storage/xtradb/srv/srv0srv.c' --- a/storage/xtradb/srv/srv0srv.c 2009-07-06 05:47:15 +0000 +++ b/storage/xtradb/srv/srv0srv.c 2009-08-27 09:48:29 +0000 @@ -1815,7 +1815,6 @@ srv_printf_innodb_monitor( ulint btr_search_sys_subtotal; ulint lock_sys_subtotal; ulint recv_sys_subtotal; - ulint io_counter_subtotal; ulint i; trx_t* trx; === modified file 'storage/xtradb/srv/srv0start.c' --- a/storage/xtradb/srv/srv0start.c 2009-08-03 20:09:53 +0000 +++ b/storage/xtradb/srv/srv0start.c 2009-08-27 09:48:29 +0000 @@ -122,20 +122,6 @@ static char* srv_monitor_file_name; #define SRV_MAX_N_PENDING_SYNC_IOS 100 -/* Avoid warnings when using purify */ - -#ifdef HAVE_valgrind -static int inno_bcmp(register const char *s1, register const char *s2, - register uint len) -{ - while ((len-- != 0) && (*s1++ == *s2++)) - ; - - return(len + 1); -} -#define memcmp(A,B,C) inno_bcmp((A),(B),(C)) -#endif - static char* srv_parse_megabytes( === modified file 'strings/decimal.c' --- a/strings/decimal.c 2009-05-06 12:03:24 +0000 +++ b/strings/decimal.c 2009-08-27 09:48:29 +0000 @@ -306,7 +306,7 @@ int decimal_actual_fraction(decimal_t *f { for (i= DIG_PER_DEC1 - ((frac - 1) % DIG_PER_DEC1); *buf0 % powers10[i++] == 0; - frac--); + frac--) {} } return frac; } @@ -500,7 +500,7 @@ static void digits_bounds(decimal_t *fro stop= (int) ((buf_end - from->buf + 1) * DIG_PER_DEC1); i= 1; } - for (; *buf_end % powers10[i++] == 0; stop--); + for (; *buf_end % powers10[i++] == 0; stop--) {} *end_result= stop; /* index of position after last decimal digit (from 0) */ } @@ -1011,7 +1011,7 @@ static int ull2dec(ulonglong from, decim sanity(to); - for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE); + for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) {} if (unlikely(intg1 > to->len)) { intg1=to->len; === added file 'support-files/ccfilter' --- a/support-files/ccfilter 1970-01-01 00:00:00 +0000 +++ b/support-files/ccfilter 2009-08-27 09:48:29 +0000 @@ -0,0 +1,104 @@ +#! /usr/bin/perl + +# Post-processor for compiler output to filter out warnings matched in +# support-files/compiler_warnings.supp. This makes it easier to check +# that no new warnings are introduced without needing to submit a build +# for Buildbot. +# +# Use by setting CC="ccfilter gcc" CXX="ccfilter gcc" before ./configure. +# +# By default, just filters the output for suppressed warnings. If the +# FAILONWARNING environment variable is set, then instead will fail the +# compile on encountering a non-suppressed warnings. + +use strict; +use warnings; + +my $suppressions; + +open STDOUT_COPY, ">&STDOUT" + or die "Failed to dup stdout: $!]n"; + +my $pid= open(PIPE, '-|'); + +if (!defined($pid)) { + die "Error: Cannot fork(): $!\n"; +} elsif (!$pid) { + # Child. + # actually want to send the STDERR to the parent, not the STDOUT. + # So shuffle things around a bit. + open STDERR, ">&STDOUT" + or die "Child: Failed to dup pipe to parent: $!\n"; + open STDOUT, ">&STDOUT_COPY" + or die "Child: Failed to dup parent stdout: $!\n"; + close STDOUT_COPY; + exec { $ARGV[0] } @ARGV; + die "Child: exec() failed: $!\n"; +} else { + # Parent. + close STDOUT_COPY; + my $cwd= qx(pwd); + chomp($cwd); + while (<PIPE>) { + my $line= $_; + if (/^(.*?):([0-9]+): [Ww]arning: (.*)$/) { + my ($file, $lineno, $msg)= ($1, $2, $3); + $file= "$cwd/$file"; + + next + if check_if_suppressed($file, $lineno, $msg); + die "$line\nGot warning, terminating.\n" + if $ENV{FAILONWARNING}; + print STDERR $line; + next; + } + + print STDERR $line; + } + close(PIPE); +} + +exit 0; + +sub check_if_suppressed { + my ($file, $lineno, $msg)= @_; + load_suppressions() unless defined($suppressions); + for my $s (@$suppressions) { + my ($file_re, $msg_re, $start, $end)= @$s; + if ($file =~ /$file_re/ && + $msg =~ /$msg_re/ && + (!defined($start) || $start <= $lineno) && + (!defined($end) || $end >= $lineno)) { + return 1; + } + } + return undef; +} + +sub load_suppressions { + # First find the suppressions file, might be we need to move up to + # the base directory. + my $path = "support-files/compiler_warnings.supp"; + my $exists; + for (1..10) { + $exists= -f $path; + last if $exists; + $path= '../'. $path; + } + die "Error: Could not find suppression file (out of source dir?).\n" + unless $exists; + + $suppressions= []; + open "F", "<", $path + or die "Error: Could not read suppression file '$path': $!\n"; + while (<F>) { + # Skip comment and empty lines. + next if /^\s*(\#.*)?$/; + die "Invalid syntax in suppression file '$path', line $.:\n$_" + unless /^\s*(.+?)\s*:\s*(.+?)\s*(?:[:]\s*([0-9]+)(?:-([0-9]+))?\s*)?$/; + my ($file_re, $line_re, $start, $end)= ($1, $2, $3, $4); + $end = $start + if defined($start) && !defined($end); + push @$suppressions, [$file_re, $line_re, $start, $end]; + } +} === modified file 'support-files/compiler_warnings.supp' --- a/support-files/compiler_warnings.supp 2008-01-11 17:39:43 +0000 +++ b/support-files/compiler_warnings.supp 2009-08-27 09:48:29 +0000 @@ -25,6 +25,9 @@ sql_yacc.cc : .*switch statement contain pars0grm.tab.c: .*'yyerrorlab' : unreferenced label.* _flex_tmp.c: .*not enough actual parameters for macro 'yywrap'.* pars0lex.l: .*conversion from 'ulint' to 'int', possible loss of data.* +btr/btr0cur\.c: .*value computed is not used.*: 3175-3375 +include/buf0buf\.ic: unused parameter ‘mtr’ +fil/fil0fil\.c: comparison between signed and unsigned : 3100-3199 # # bdb is not critical to keep up to date @@ -41,6 +44,12 @@ db_vrfy.c : .*comparison is always false .*/cmd-line-utils/readline/.* : .* # +# Ignore some warnings in libevent, which is not maintained by us. +# +.*/extra/libevent/.* : .*unused parameter.* +.*/extra/libevent/select\.c : .*comparison between signed and unsigned.* : 270-280 + +# # Ignore all conversion warnings on windows 64 # (Is safe as we are not yet supporting strings >= 2G) # @@ -75,6 +84,17 @@ db_vrfy.c : .*comparison is always false storage/maria/ma_pagecache.c: .*'info_check_pin' defined but not used # +# I think these are due to mix of C and C++. +# +storage/pbxt/ : typedef.*was ignored in this declaration + + +# +# Groff warnings on OpenSUSE. +# +.*/dbug/.*(groff|<standard input>) : .* + +# # Unexplanable (?) stuff # listener.cc : .*conversion from 'SOCKET' to 'int'.*
participants (1)
-
knielsen@knielsen-hq.org