From c94ccb237e5f8b0f72c742746aa49f8ff8440f98 Mon Sep 17 00:00:00 2001
From: Tor Didriksen <tor.didriksen@oracle.com>
Date: Fri, 14 Jun 2013 10:52:23 +0200
Subject: [PATCH] Bug#16729109: FIX COMPILATION WARNINGS WITH GCC 4.8 Backport
 to 5.5 (external Bug#69407 Build warnings with mysql)

support-files/build-tags:
  Run etags on sql_yacc.yy, ignore other .yy files
unittest/mysys/explain_filename-t.cc:
  NO_PLAN seems to fail on some platforms, use the actual number instead.
---
 include/my_global.h                  | 4 ++--
 mysys/CMakeLists.txt                 | 7 ++++++-
 sql/debug_sync.cc                    | 4 ++--
 sql/field.cc                         | 6 +++---
 storage/myisam/mi_checksum.c         | 3 +--
 storage/myisam/mi_key.c              | 4 ++--
 storage/myisam/mi_packrec.c          | 4 ++--
 support-files/build-tags             | 2 +-
 unittest/mysys/explain_filename-t.cc | 2 +-
 9 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/include/my_global.h b/include/my_global.h
index 85f2078e36..0d43964234 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+   Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -391,7 +391,7 @@ C_MODE_END
 #define compile_time_assert(X)                                  \
   do                                                            \
   {                                                             \
-    typedef char compile_time_assert[(X) ? 1 : -1];             \
+    typedef char compile_time_assert[(X) ? 1 : -1] __attribute__((unused)); \
   } while(0)
 #endif
 
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 814f093c2d..95d3e568be 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -69,6 +69,11 @@ TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY}
  ${LIBNSL} ${LIBM} ${LIBRT})
 DTRACE_INSTRUMENT(mysys)
 
+# Need explicit pthread for gcc -fsanitize=address
+IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
+  TARGET_LINK_LIBRARIES(mysys pthread)
+ENDIF()
+
 ADD_EXECUTABLE(thr_lock thr_lock.c)
 TARGET_LINK_LIBRARIES(thr_lock mysys)
 SET_TARGET_PROPERTIES(thr_lock PROPERTIES COMPILE_FLAGS "-DMAIN")
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index 1575bca427..1dc40c978d 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1737,7 +1737,7 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
     if (action->wait_for.length())
     {
       mysql_mutex_t *old_mutex;
-      mysql_cond_t  *old_cond;
+      mysql_cond_t  *old_cond= NULL;
       int             error= 0;
       struct timespec abstime;
 
diff --git a/sql/field.cc b/sql/field.cc
index 749d5d8047..c65346423a 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+   Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -7380,7 +7380,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
     if (!String::needs_conversion(length, cs, field_charset, &dummy_offset))
     {
       Field_blob::store_length(length);
-      bmove(ptr+packlength,(char*) &from,sizeof(char*));
+      bmove(ptr+packlength, &from, sizeof(char*));
       return 0;
     }
     if (tmpstr.copy(from, length, cs))
@@ -7897,7 +7897,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
       value.copy(from, length, cs);
       from= value.ptr();
     }
-    bmove(ptr + packlength, (char*) &from, sizeof(char*));
+    bmove(ptr + packlength, &from, sizeof(char*));
   }
   return 0;
 
diff --git a/storage/myisam/mi_checksum.c b/storage/myisam/mi_checksum.c
index 3d95eb2b60..97503878e5 100644
--- a/storage/myisam/mi_checksum.c
+++ b/storage/myisam/mi_checksum.c
@@ -33,8 +33,7 @@ ha_checksum mi_checksum(MI_INFO *info, const uchar *buf)
       length=_mi_calc_blob_length(rec->length-
 					portable_sizeof_char_ptr,
 					buf);
-      memcpy((char*) &pos, buf+rec->length- portable_sizeof_char_ptr,
-	     sizeof(char*));
+      memcpy(&pos, buf+rec->length- portable_sizeof_char_ptr, sizeof(char*));
       break;
     }
     case FIELD_VARCHAR:
diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c
index 5c3d492295..96b8c14c6a 100644
--- a/storage/myisam/mi_key.c
+++ b/storage/myisam/mi_key.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -418,7 +418,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
 	goto err;
 #endif
       memcpy(record+keyseg->start+keyseg->bit_start,
-	     (char*) &blob_ptr,sizeof(char*));
+	     &blob_ptr,sizeof(char*));
       memcpy(blob_ptr,key,length);
       blob_ptr+=length;
 
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index a1a03e20aa..8548b3ebd9 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1051,7 +1051,7 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff,
     }
     decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length);
     _my_store_blob_length((uchar*) to,pack_length,length);
-    memcpy((char*) to+pack_length, &bit_buff->blob_pos, sizeof(char*));
+    memcpy(to+pack_length, &bit_buff->blob_pos, sizeof(char*));
     bit_buff->blob_pos+=length;
   }
 }
diff --git a/support-files/build-tags b/support-files/build-tags
index b5386dc79c..9c43e021c4 100755
--- a/support-files/build-tags
+++ b/support-files/build-tags
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 rm -f TAGS
-filter='\.cc$\|\.c$\|\.h$\|\.yy$'
+filter='\.cc$\|\.c$\|\.h$\|sql_yacc\.yy$'
 
 list="find . -type f"
 bzr root >/dev/null 2>/dev/null && list="bzr ls --from-root -R --kind=file --versioned"
diff --git a/unittest/mysys/explain_filename-t.cc b/unittest/mysys/explain_filename-t.cc
index 09ebe1768d..7eda24fe5d 100644
--- a/unittest/mysys/explain_filename-t.cc
+++ b/unittest/mysys/explain_filename-t.cc
@@ -64,7 +64,7 @@ void test_1(const char *in, const char *exp, enum_explain_filename_mode mode)
 int main()
 {
   setup();
-  plan(NO_PLAN);
+  plan(22);
 
   test_1("test/t1.ibd",
          "Database \"test\", Table \"t1.ibd\"",
-- 
2.30.9