Skip to content

Commit

Permalink
Bug#27558169 BACKPORT TO 5.7 BUG #26826272: REMOVE GCC 8 WARNINGS [no…
Browse files Browse the repository at this point in the history
…close]

MySQL 5.7 should compile warning-free (ie., maintainer mode should work)
also with GCC 8.

This is a backport of similar patches from current MySQL trunk.

This patch silences warnings in 3rd party code, and test plugins.

Change-Id: I30aaa6697396028cc83e69e1236cbc8dc835cd21
  • Loading branch information
Tor Didriksen committed Mar 8, 2018
1 parent 34d6abe commit a091d6b
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 13 deletions.
14 changes: 13 additions & 1 deletion cmd-line-utils/libedit/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2018, 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
Expand All @@ -18,6 +18,8 @@ INCLUDE(CheckIncludeFile)
include(CheckFunctionExists)
CHECK_INCLUDE_FILES(term.h HAVE_TERM_H)

INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)

SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
CHECK_CXX_SOURCE_COMPILES("
#include <term.h>
Expand Down Expand Up @@ -154,6 +156,16 @@ ${CMAKE_CURRENT_BINARY_DIR}
${CURSES_INCLUDE_PATH}
)

MY_CHECK_C_COMPILER_FLAG("-Wstringop-overflow" HAVE_STRINGOP_OVERFLOW)
IF(HAVE_STRINGOP_OVERFLOW)
ADD_COMPILE_FLAGS(
history.c
historyn.c
readline.c
COMPILE_FLAGS -Wno-stringop-overflow
)
ENDIF()

SET(LIBEDIT_SOURCES
chared.c
chartype.c
Expand Down
13 changes: 11 additions & 2 deletions extra/yassl/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2018, 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
Expand All @@ -25,11 +25,20 @@ ADD_DEFINITIONS(${SSL_DEFINES})
ADD_DEFINITIONS(-Dget_tty_password_ext=yassl_mysql_get_tty_password_ext)
ADD_DEFINITIONS(-Dget_tty_password=yassl_mysql_get_tty_password)

INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)

MY_CHECK_CXX_COMPILER_FLAG("-Wstringop-overflow" HAVE_STRINGOP_OVERFLOW)
IF(HAVE_STRINGOP_OVERFLOW)
ADD_COMPILE_FLAGS(
src/ssl.cpp
src/yassl_imp.cpp
COMPILE_FLAGS -Wno-stringop-overflow
)
ENDIF()

MY_CHECK_CXX_COMPILER_FLAG("-Wno-unused-const-variable" HAVE_NO_UNUSED_CONST_VAR)

IF(CMAKE_GENERATOR MATCHES "Xcode" AND HAVE_NO_UNUSED_CONST_VAR)
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)
ADD_COMPILE_FLAGS(
src/yassl_int.cpp
src/socket_wrapper.cpp
Expand Down
4 changes: 2 additions & 2 deletions mysys/my_gethwaddr.c
@@ -1,4 +1,4 @@
/* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2004, 2018, 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
Expand Down Expand Up @@ -109,7 +109,7 @@ my_bool my_gethwaddr(uchar *to)
{
/* Reset struct, copy interface name */
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifri->ifr_name, sizeof(ifr.ifr_name));
memcpy(ifr.ifr_name, ifri->ifr_name, sizeof(ifr.ifr_name));

/* Get HW address, break if not 0 */
if (ioctl(fd, SIOCGIFHWADDR, &ifr) >= 0)
Expand Down
62 changes: 61 additions & 1 deletion plugin/innodb_memcached/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2018, 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
Expand All @@ -13,6 +13,66 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
IF(WITH_INNODB_MEMCACHED AND UNIX)
MY_CHECK_C_COMPILER_FLAG("-Wdiscarded-qualifiers" HAVE_DISCARDED_QUALIFIERS)
IF (HAVE_DISCARDED_QUALIFIERS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-discarded-qualifiers")
ENDIF()
MY_CHECK_C_COMPILER_FLAG("-Wimplicit-fallthrough" HAVE_IMPLICIT_FALLTHROUGH)
IF (HAVE_IMPLICIT_FALLTHROUGH)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-fallthrough")
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-compare")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-undef")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-vla")

MY_CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement"
HAVE_DECLARATION_AFTER_STATEMENT)
IF (HAVE_DECLARATION_AFTER_STATEMENT)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-declaration-after-statement")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wduplicate-decl-specifier"
HAVE_DUPLICATE_DECL_SPECIFIER)
IF(HAVE_DUPLICATE_DECL_SPECIFIER)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-duplicate-decl-specifier")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wint-conversion" HAVE_INT_CONVERSION)
IF(HAVE_INT_CONVERSION)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-int-conversion")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wstringop-overflow" HAVE_STRINGOP_OVERFLOW)
IF(HAVE_STRINGOP_OVERFLOW)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-overflow")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wstringop-truncation" HAVE_STRINGOP_TRUNCATION)
IF(HAVE_STRINGOP_TRUNCATION)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-truncation")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wsuggest-attribute=format"
HAVE_SUGGEST_ATTRIBUTE_FORMAT)
IF(HAVE_SUGGEST_ATTRIBUTE_FORMAT)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-suggest-attribute=format")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wunused-but-set-parameter"
HAVE_UNUSED_BUT_SET_PARAMETER)
IF(HAVE_UNUSED_BUT_SET_PARAMETER)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-parameter")
ENDIF()

MY_CHECK_C_COMPILER_FLAG("-Wunused-but-set-variable"
HAVE_UNUSED_BUT_SET_VARIABLE)
IF(HAVE_UNUSED_BUT_SET_VARIABLE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
ENDIF()

ADD_SUBDIRECTORY(daemon_memcached)
ADD_SUBDIRECTORY(innodb_memcache)
ENDIF()
Expand Down
7 changes: 6 additions & 1 deletion plugin/innodb_memcached/daemon_memcached/daemon/memcached.c
Expand Up @@ -3583,7 +3583,12 @@ static size_t tokenize_command(char *command, token_t *tokens, const size_t max_
return ntokens;
}

static void detokenize(token_t *tokens, int ntokens, char **out, int *nbytes) {
#ifdef INNODB_MEMCACHED
static void detokenize(token_t *tokens, size_t ntokens, char **out, int *nbytes)
#else
static void detokenize(token_t *tokens, int ntokens, char **out, int *nbytes)
#endif
{
int i, nb;
char *buf, *p;

Expand Down
3 changes: 3 additions & 0 deletions plugin/innodb_memcached/daemon_memcached/daemon/thread.c
Expand Up @@ -19,6 +19,9 @@

#define INNODB_MEMCACHED

extern void my_thread_end();
extern void my_thread_init();

static char devnull[8192];
extern volatile sig_atomic_t memcached_shutdown;

Expand Down
18 changes: 18 additions & 0 deletions plugin/innodb_memcached/innodb_memcache/src/hash_item_util.c
@@ -1,7 +1,25 @@
/*
Copyright (c) 2017, 2018, 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 the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/



#include "hash_item_util.h"

#include <arpa/inet.h>

char * hash_item_get_key(const hash_item* item) {
char *ret = (void*)(item + 1);
if (item->iflag & ITEM_WITH_CAS) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/keyring/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2018, 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
Expand All @@ -15,7 +15,7 @@

INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)

INCLUDE_DIRECTORIES(${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
INCLUDE_DIRECTORIES(SYSTEM ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common)

SET(
Expand Down
9 changes: 8 additions & 1 deletion plugin/test_service_sql_api/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2018, 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
Expand All @@ -15,6 +15,13 @@
#
# Test session API

# Silence warnings in test code for now.
# Bug#27572037 REFACTOR CODE IN TEST_SERVICE_SQL_API
MY_CHECK_CXX_COMPILER_FLAG("-Wstringop-truncation" HAVE_STRINGOP_TRUNCATION)
IF(HAVE_STRINGOP_TRUNCATION)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation")
ENDIF()

MYSQL_ADD_PLUGIN(test_session_in_thd test_session_in_thd.cc
MODULE_ONLY MODULE_OUTPUT_NAME "libtest_session_in_thd")

Expand Down
10 changes: 9 additions & 1 deletion regex/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2018, 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
Expand All @@ -15,6 +15,14 @@

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)

MY_CHECK_C_COMPILER_FLAG("-Wstringop-truncation" HAVE_STRINGOP_TRUNCATION)
IF(HAVE_STRINGOP_TRUNCATION)
ADD_COMPILE_FLAGS(
main.c
COMPILE_FLAGS -Wno-stringop-truncation
)
ENDIF()

SET(REGEX_SOURCES regcomp.c regerror.c regexec.c regfree.c reginit.c)
ADD_CONVENIENCE_LIBRARY(regex ${REGEX_SOURCES})

Expand Down
4 changes: 2 additions & 2 deletions unittest/gunit/keyring/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2018, 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
Expand All @@ -18,7 +18,7 @@ IF(NOT GMOCK_FOUND)
RETURN()
ENDIF()

INCLUDE_DIRECTORIES(${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
INCLUDE_DIRECTORIES(SYSTEM ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})

INCLUDE_DIRECTORIES(
${GMOCK_INCLUDE_DIRS}
Expand Down

0 comments on commit a091d6b

Please sign in to comment.