Commit 592379fc authored by unknown's avatar unknown

Fix most Compiler warnings seen in buildbot.

Add suppressions for a few warnings that cannot be meaningfully fixed by
MariaDB developers.

Changes for XtraDB, PBXT, and YaSSL also submitted upstream.

Also add a `ccfilter` wrapper that can be used to filter out suppressed warnings in a
local build (to check that new warnings are not introduced).


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/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.
parent 03db11cf
......@@ -689,8 +689,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
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)
......
......@@ -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
......
......@@ -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;
......
......@@ -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, BufferOutput buffer)
// 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;
......
......@@ -1304,7 +1304,7 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
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& ssl)
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
......
......@@ -1833,7 +1833,7 @@ SSL_CTX::GetCA_List() const
}
const VerifyCallback SSL_CTX::getVerifyCallback() const
VerifyCallback SSL_CTX::getVerifyCallback() const
{
return verifyCallback_;
}
......
......@@ -95,11 +95,12 @@ inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz)
{
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);
}
}
......
......@@ -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, const byte* encoded, word32 sz)
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, const byte* encoded, word32 sz)
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, const byte* encoded, word32 sz)
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, const byte* encoded, word32 sz)
source.SetError(DSA_SZ_E);
return 0;
}
}
memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen);
source.advance(sLen);
......
......@@ -81,12 +81,13 @@ my_bool my_compress(uchar *packet, size_t *len, size_t *complen)
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));
}
......
......@@ -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, const char *info)
}
DBUG_VOID_RETURN;
}
#endif
static void close_server_sock()
......
......@@ -148,7 +148,7 @@ static uint parse_name(TYPELIB *lib, const char **strpos, const char *end,
}
}
else
for (; pos != end && *pos != '=' && *pos !=',' ; pos++);
for (; pos != end && *pos != '=' && *pos !=',' ; pos++) {}
uint var_len= (uint) (pos - start);
/* Determine which flag it is */
......
......@@ -493,8 +493,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
/* 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_CREATE_INFO *create_info,
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
......
......@@ -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"
/*
......@@ -3137,7 +3139,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,
......
......@@ -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. */
......
......@@ -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;
......
......@@ -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(
......
......@@ -306,7 +306,7 @@ int decimal_actual_fraction(decimal_t *from)
{
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 *from, int *start_result, int *end_result)
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, decimal_t *to)
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;
......
#! /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];
}
}
......@@ -25,6 +25,9 @@ sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.*
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
......@@ -40,6 +43,12 @@ db_vrfy.c : .*comparison is always false due to limited range of data type.*
#
.*/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)
......@@ -74,6 +83,17 @@ db_vrfy.c : .*comparison is always false due to limited range of data type.*
#
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
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment