Skip to content

Commit

Permalink
Bug #26597243: AMBIGUOUS INCLUDE PATHS [noclose, zlib]
Browse files Browse the repository at this point in the history
Canonicalize all paths leading into zlib so that they are system
includs, then resort #include statements in the affected files.
Also clean up CMake inclusions of zlib so that there's only one,
and that it's a system include.

Change-Id: Ic5adef346f0f8a170ac30ee574eb67737aed92f0
  • Loading branch information
Steinar H. Gunderson committed Aug 16, 2017
1 parent 817f1fd commit b244758
Show file tree
Hide file tree
Showing 34 changed files with 32 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ INCLUDE_DIRECTORIES(
# Add bundled or system zlib.
MYSQL_CHECK_ZLIB_WITH_COMPRESS()
IF(BUILD_BUNDLED_ZLIB)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/extra/zlib)
INCLUDE_DIRECTORIES(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/extra/zlib ${CMAKE_CURRENT_BINARY_DIR}/extra/zlib)
ENDIF()
# Add bundled yassl/taocrypt or system openssl or custom openssl
MYSQL_CHECK_SSL()
Expand Down
1 change: 0 additions & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/mysys_ssl
${ZLIB_INCLUDE_DIR}
${LZ4_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/libmysql
Expand Down
2 changes: 1 addition & 1 deletion client/dump/compression_zlib_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

#include <string.h>
#include <sys/types.h>
#include <zlib.h>
#include <functional>

#include "client/base/mutex.h"
#include "client/dump/abstract_output_writer_wrapper.h"
#include "client/dump/i_output_writer.h"
#include "my_inttypes.h"
#include "zlib.h"

namespace Mysql{
namespace Tools{
Expand Down
3 changes: 1 addition & 2 deletions cmake/plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ MACRO(MYSQL_ADD_PLUGIN)
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${CMAKE_SOURCE_DIR}/sql/auth
${SSL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR})
${SSL_INCLUDE_DIRS})

LIST(GET ARG_DEFAULT_ARGS 0 plugin)
SET(SOURCES ${ARG_DEFAULT_ARGS})
Expand Down
1 change: 0 additions & 1 deletion cmake/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
MACRO (MYSQL_USE_BUNDLED_ZLIB)
SET(BUILD_BUNDLED_ZLIB 1)
SET(ZLIB_LIBRARY zlib CACHE INTERNAL "Bundled zlib library")
SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extra/zlib)
SET(ZLIB_FOUND TRUE)
SET(WITH_ZLIB "bundled" CACHE STRING "Use bundled zlib")
ADD_SUBDIRECTORY(extra/zlib)
Expand Down
1 change: 0 additions & 1 deletion components/logging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/components/logging
${CMAKE_SOURCE_DIR}/components/mysql_server
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${ZLIB_INCLUDE_DIR}
)

REMOVE_DEFINITIONS(-DMYSQL_SERVER)
Expand Down
1 change: 0 additions & 1 deletion components/mysql_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${CMAKE_SOURCE_DIR}/storage/perfschema
${CMAKE_SOURCE_DIR}/sql/auth
${ZLIB_INCLUDE_DIR}
)

SET(MYSQL_SERVER_COMPONENT_SOURCES
Expand Down
1 change: 0 additions & 1 deletion extra/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ENDIF()

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-2.6.1/src
${ZLIB_INCLUDE_DIR}
)

SET(PROTO_SRC_DIR
Expand Down
8 changes: 2 additions & 6 deletions libbinlogevents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2017, 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,11 +18,7 @@ INCLUDE(configure.cmake)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${CMAKE_SOURCE_DIR}/libbinlogevents/export
# ZLIB_INCLUDE_DIR points to ${CMAKE_SOURCE_DIR}/zlib,
# when compiled with MySQL server version (< 5.7).
# It is NULL otherwise.
${ZLIB_INCLUDE_DIR})
${CMAKE_SOURCE_DIR}/libbinlogevents/export)

CONFIGURE_FILE(binlog_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/include/binlog_config.h)
Expand Down
9 changes: 1 addition & 8 deletions libbinlogstandalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,10 @@ ADD_DEFINITIONS(-DSTANDALONE_BINLOG)
# INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
#ENDIF()

FIND_PACKAGE(ZLIB REQUIRED)


INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${CMAKE_CURRENT_BINARY_DIR}/../libbinlogevents/include
${CMAKE_SOURCE_DIR}/libbinlogevents/export
# ZLIB_INCLUDE_DIR points to ${CMAKE_SOURCE_DIR}/zlib,
# when compiled with MySQL server version (< 5.7).
# It is NULL otherwise.
${ZLIB_INCLUDE_DIR})
${CMAKE_SOURCE_DIR}/libbinlogevents/export)

ADD_SUBDIRECTORY(src)

Expand Down
3 changes: 1 addition & 2 deletions libmysql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/strings
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${SSL_INCLUDE_DIRS}
${SSL_INTERNAL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR})
${SSL_INTERNAL_INCLUDE_DIRS})
ADD_DEFINITIONS(${SSL_DEFINES})

SET(CLIENT_API_FUNCTIONS
Expand Down
2 changes: 1 addition & 1 deletion mysys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)

SET(MYSYS_SOURCES
array.cc
Expand Down
1 change: 0 additions & 1 deletion mysys/my_compress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "my_sys.h"
#include "mysql/service_mysql_alloc.h"
#include "mysys_priv.h"
#include "zlib.h"

/*
This replaces the packet with a compressed packet
Expand Down
1 change: 0 additions & 1 deletion rapid/plugin/x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ INCLUDE_DIRECTORIES(SYSTEM
${PROTOBUF_INCLUDE_DIRS}
${LIBEVENT_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
)

SET(MYSQLX_PROTBUF_AND_PROTOCOL_LIB
Expand Down
1 change: 0 additions & 1 deletion rapid/plugin/x/tests/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ INCLUDE_DIRECTORIES(SYSTEM
${PROTOBUF_INCLUDE_DIRS}
${LIBEVENT_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
)

MYSQL_ADD_EXECUTABLE(${XTEST_EXE_NAME}
Expand Down
1 change: 0 additions & 1 deletion rapid/unittest/gunit/xplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ ADD_DEFINITIONS(${GMOCK_CFLAGS} -DUSE_MYSQLX_FULL_PROTO -DXPLUGIN_UNIT_TESTS)
INCLUDE_DIRECTORIES(SYSTEM
${PROTOBUF_INCLUDE_DIRS}
${SSL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${LIBEVENT_INCLUDE_DIR}
${GMOCK_INCLUDE_DIRS}
${GTEST_INCLUDE_DIR}
Expand Down
1 change: 0 additions & 1 deletion sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${CMAKE_SOURCE_DIR}/extra/regex
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/sql
${LZ4_INCLUDE_DIR}
Expand Down
4 changes: 1 addition & 3 deletions sql/item_strfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "sql/item_strfunc.h"

#include <zlib.h>
#include <algorithm>
#include <atomic>
#include <cmath> // std::isfinite
Expand Down Expand Up @@ -86,7 +87,6 @@
#include "sql/val_int_compare.h" // Integer_value
#include "template_utils.h"
#include "typelib.h"
#include "zlib.h"

using std::min;
using std::max;
Expand Down Expand Up @@ -4245,8 +4245,6 @@ longlong Item_func_crc32::val_int()
return (longlong) crc32(0L, (uchar*)res->ptr(), res->length());
}

#include "zlib.h"

String *Item_func_compress::val_str(String *str)
{
int err= Z_OK, code;
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/btr/btr0cur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Created 10/16/1994 Heikki Tuuri
#include "my_inttypes.h"
#include "row0upd.h"
#ifndef UNIV_HOTBACKUP
#include <zlib.h>

#include "btr0btr.h"
#include "btr0sea.h"
#include "buf0lru.h"
Expand All @@ -70,7 +72,6 @@ Created 10/16/1994 Heikki Tuuri
#include "srv0start.h"
#include "trx0rec.h"
#include "trx0roll.h"
#include "zlib.h"

/** Buffered B-tree operation types, introduced as part of delete buffering. */
enum btr_op_t {
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/buf/checksum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Created Aug 11, 2011 Vasil Dimov
*******************************************************/

#include <sys/types.h>
#include <zlib.h>

#include "buf0buf.h"
#include "buf0types.h"
Expand All @@ -35,7 +36,6 @@ Created Aug 11, 2011 Vasil Dimov
#include "univ.i"
#include "ut0crc32.h"
#include "ut0rnd.h"
#include "zlib.h"

/** the macro MYSQL_SYSVAR_ENUM() requires "long unsigned int" and if we
use srv_checksum_algorithm_t here then we get a compiler error:
Expand Down
10 changes: 4 additions & 6 deletions storage/innobase/fts/fts0opt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,28 @@ Completed 2011/7/10 Sunny and Jimmy Yang
***********************************************************************/

#include "ha_prototypes.h"
#include "current_thd.h"

#include <math.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include <zlib.h>

#include "current_thd.h"
#include "dict0dd.h"
#include "fts0fts.h"
#include "fts0opt.h"
#include "fts0priv.h"
#include "fts0types.h"
#include "ha_prototypes.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "os0thread-create.h"
#include "que0types.h"
#include "row0sel.h"
#include "sql_thd_internal_api.h"
#include "srv0start.h"
#include "ut0list.h"
#include "ut0wqueue.h"
#include "zlib.h"
#include "os0thread-create.h"
#include "sql_thd_internal_api.h"

/** The FTS optimize thread's work queue. */
static ib_wqueue_t* fts_optimize_wq;
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/dict0sdi-decompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#ifndef DICT_SDI_DECOMPRESS_H
#define DICT_SDI_DECOMPRESS_H

#include "zlib.h"
#include <zlib.h>

/** Decompress SDI record */
class Sdi_Decompressor {
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/page0zip.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Created June 2005 by Marko Makela
#endif

#include <sys/types.h>
#include <zlib.h>

#include "buf0buf.h"
#include "buf0checksum.h"
Expand All @@ -47,7 +48,6 @@ Created June 2005 by Marko Makela
#include "trx0types.h"
#include "univ.i"
#include "ut0crc32.h"
#include "zlib.h"

/* Compression level to be used by zlib. Settable by user. */
extern uint page_zip_level;
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/page/page0zip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ const byte field_ref_zero[FIELD_REF_SIZE] = {
0, 0, 0, 0, 0,
};

#include <zlib.h>

#include "btr0cur.h"
#include "dict0dict.h"
#include "log0recv.h"
#include "mtr0log.h"
#include "page0page.h"
#include "page0types.h"
#include "zlib.h"
#ifndef UNIV_HOTBACKUP
# include "btr0sea.h"
# include "buf0buf.h"
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/page/zipdecompress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ external tools. */

#include <stdarg.h>
#include <sys/types.h>
#include <zlib.h>

#include "btr0btr.h"
#include "mem0mem.h"
Expand All @@ -38,7 +39,6 @@ external tools. */
#include "page/zipdecompress.h"
#include "page0page.h"
#include "rem0rec.h"
#include "zlib.h"

/* Enable some extra debugging output. This code can be enabled
independently of any UNIV_ debugging conditions. */
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Created 2/16/1996 Heikki Tuuri
#include "trx0trx.h"
#include "ut0mem.h"
#ifndef UNIV_HOTBACKUP
# include <zlib.h>

# include "arch0arch.h"
# include "btr0pcur.h"
# include "btr0sea.h"
Expand Down Expand Up @@ -106,7 +108,6 @@ Created 2/16/1996 Heikki Tuuri
# include "usr0sess.h"
# include "ut0crc32.h"
# include "ut0new.h"
# include "zlib.h"

#ifdef HAVE_LZO1X
#include <lzo/lzo1x.h>
Expand Down
1 change: 0 additions & 1 deletion storage/ndb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}/include

# Util library includes
${ZLIB_INCLUDE_DIR}
${EDITLINE_INCLUDE_DIR})

# The root of storage/ndb/
Expand Down
3 changes: 1 addition & 2 deletions storage/ndb/ndb_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ IF(NOT DEFINED WITH_ZLIB)
# Hardcode use of the bundled zlib if not set by MySQL
MESSAGE(STATUS "Using bundled zlib (hardcoded)")
SET(ZLIB_LIBRARY zlib)
SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extra/zlib)
INCLUDE_DIRECTORIES(SYSTEM ${CMAKE_SOURCE_DIR}/extra/zlib)
ENDIF()
NDB_REQUIRE_VARIABLE(ZLIB_LIBRARY)
NDB_REQUIRE_VARIABLE(ZLIB_INCLUDE_DIR)

IF(WITH_CLASSPATH)
MESSAGE(STATUS "Using supplied classpath: ${WITH_CLASSPATH}")
Expand Down
10 changes: 5 additions & 5 deletions storage/ndb/src/common/util/ndbzio.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
* This is a casual hack to do static memory allocation
* (needed by NDB)
*/
#include "../../../../extra/zlib/zutil.h"
#include "../../../../extra/zlib/zlib.h"
#include "../../../../extra/zlib/inftrees.h"
#include "../../../../extra/zlib/inflate.h"
#include "../../../../extra/zlib/deflate.h"
#include <zutil.h>
#include <zlib.h>
#include <inftrees.h>
#include <inflate.h>
#include <deflate.h>

#include <util/ndbzio.h>

Expand Down
1 change: 0 additions & 1 deletion unittest/gunit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ ENDIF()
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${ZLIB_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/extra/regex
${CMAKE_SOURCE_DIR}/storage/example
${CMAKE_SOURCE_DIR}/storage/temptable/include
Expand Down
1 change: 0 additions & 1 deletion unittest/gunit/innodb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

INCLUDE_DIRECTORIES(
${GTEST_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/storage/innobase/include
${CMAKE_SOURCE_DIR}/unittest/gunit
Expand Down
1 change: 0 additions & 1 deletion utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${ZLIB_INCLUDE_DIR}
${LZ4_INCLUDE_DIR})

INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)
Expand Down
Loading

0 comments on commit b244758

Please sign in to comment.