← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2720)

 

#At lp:maria

 2720 knielsen@xxxxxxxxxxxxxxx	2009-08-24
      Fix most Compiler warnings seen in buildbot.
      This includes fixing a bug in option parsing; test case for this bug added.
      Also add suppressions for a few warnings that cannot be meaningfully fixed by
      MariaDB developers.
      added:
        mysql-test/r/plugin_load2.result
        mysql-test/t/plugin_load2-master.opt
        mysql-test/t/plugin_load2.test
        support-files/ccfilter
      modified:
        mysys/my_compress.c
        mysys/my_getopt.c
        sql/mysqld.cc
        storage/xtradb/fil/fil0fil.c
        storage/xtradb/mtr/mtr0mtr.c
        storage/xtradb/srv/srv0srv.c
        storage/xtradb/srv/srv0start.c
        support-files/compiler_warnings.supp

=== added file 'mysql-test/r/plugin_load2.result'
--- a/mysql-test/r/plugin_load2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/plugin_load2.result	2009-08-24 13:56:18 +0000
@@ -0,0 +1,2 @@
+SELECT @@global.example_enum_var = 'e2';
+ERROR HY000: Unknown system variable 'example_enum_var'

=== added file 'mysql-test/t/plugin_load2-master.opt'
--- a/mysql-test/t/plugin_load2-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/plugin_load2-master.opt	2009-08-24 13:56:18 +0000
@@ -0,0 +1,3 @@
+$EXAMPLE_PLUGIN_OPT
+"--plugin-load=;EXAMPLE=ha_example.so;"
+--loose-plugin-example-enum-var=nonexistientvalue

=== added file 'mysql-test/t/plugin_load2.test'
--- a/mysql-test/t/plugin_load2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/plugin_load2.test	2009-08-24 13:56:18 +0000
@@ -0,0 +1,12 @@
+--source include/have_example_plugin.inc
+
+# Test for bug in parsing plugin enum option.
+# The bug was that the error from parsing a non-existent value was not properly
+# handled, so the variable was assigned some arbitrary wrong value.
+#
+# We test this by passing --loose-plugin-example-enum-var=nonexistientvalue in
+# the .opt file of the test case, and check that the variable is not wrongly
+# set to a value in this case.
+
+--error 1193
+SELECT @@global.example_enum_var = 'e2';

=== 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-24 13:56:18 +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 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2009-05-20 15:34:34 +0000
+++ b/mysys/my_getopt.c	2009-08-24 13:56:18 +0000
@@ -603,6 +603,7 @@ static int setval(const struct my_option
 		  my_bool set_maximum_value)
 {
   int err= 0;
+  int pos;
 
   if (value && argument)
   {
@@ -647,7 +648,9 @@ static int setval(const struct my_option
 	return EXIT_OUT_OF_MEMORY;
       break;
     case GET_ENUM:
-      if (((*(ulong *)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0)
+      pos = find_type(argument, opts->typelib, 2) - 1;
+      (*(ulong *)result_pos)= pos;
+      if (pos < 0)
         return EXIT_ARGUMENT_INVALID;
       break;
     case GET_SET:

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-05-19 09:28:05 +0000
+++ b/sql/mysqld.cc	2009-08-24 13:56:18 +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 '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-24 13:56:18 +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-24 13:56:18 +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-24 13:56:18 +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-24 13:56:18 +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(

=== added file 'support-files/ccfilter'
--- a/support-files/ccfilter	1970-01-01 00:00:00 +0000
+++ b/support-files/ccfilter	2009-08-24 13:56:18 +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-24 13:56:18 +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)
 #