Skip to content

Commit 53508b2

Browse files
committed
Bug #33975638: Enable the deprecation warnings on windows
1. removed the disablement of warning 4996 from the global scope 2. replaced with bunch of MSVC compiler defines to limit deprecated warnings 3. Added disablement of WL#4996 to libevent and icu builds 4. Removed some stale Win98 support code Change-Id: I0457a660769deb173d419dac3fa36865e8cc9e4b
1 parent aaea989 commit 53508b2

File tree

8 files changed

+48
-55
lines changed

8 files changed

+48
-55
lines changed

cmake/os/Windows.cmake

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,33 @@ IF(MSVC)
195195
STRING_APPEND(CMAKE_CXX_FLAGS " /MP")
196196
ENDIF()
197197

198-
IF(WIN32_CLANG)
199-
# Adding -Wno-deprecated-declarations does not silence warnings,
200-
# so add misc. macros instead.
201-
202-
# warning STL4015 The std::iterator class
203-
# (used as a base class to provide typedefs) is deprecated in C++17
204-
STRING_APPEND(CMAKE_CXX_FLAGS
205-
" -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING")
206-
207-
# 'strcpy' is deprecated. This function or variable may be unsafe.
208-
STRING_APPEND(CMAKE_C_FLAGS " -D_CRT_SECURE_NO_WARNINGS")
209-
STRING_APPEND(CMAKE_CXX_FLAGS " -D_CRT_SECURE_NO_WARNINGS")
210-
211-
# 'getpid' is deprecated. The POSIX name for this item is deprecated.
212-
# Instead use the ISO C and C++ conformant name _getpid.
213-
STRING_APPEND(CMAKE_C_FLAGS " -D_CRT_NONSTDC_NO_DEPRECATE")
214-
STRING_APPEND(CMAKE_CXX_FLAGS " -D_CRT_NONSTDC_NO_DEPRECATE")
215-
ENDIF()
198+
#TODO(Bug#33985941): update the code and remove the disabled warnings
199+
200+
# warning STL4015 The std::iterator class
201+
# (used as a base class to provide typedefs) is deprecated in C++17
202+
STRING_APPEND(CMAKE_CXX_FLAGS
203+
" -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING")
204+
205+
# 'strcpy' is deprecated. This function or variable may be unsafe.
206+
STRING_APPEND(CMAKE_C_FLAGS " -D_CRT_SECURE_NO_WARNINGS")
207+
STRING_APPEND(CMAKE_CXX_FLAGS " -D_CRT_SECURE_NO_WARNINGS")
208+
209+
# 'getpid' is deprecated. The POSIX name for this item is deprecated.
210+
# Instead use the ISO C and C++ conformant name _getpid.
211+
STRING_APPEND(CMAKE_C_FLAGS " -D_CRT_NONSTDC_NO_DEPRECATE")
212+
STRING_APPEND(CMAKE_CXX_FLAGS " -D_CRT_NONSTDC_NO_DEPRECATE")
213+
214+
# 'inet_addr' is deprecated. Use inet_pton()
215+
STRING_APPEND(CMAKE_C_FLAGS " -D_WINSOCK_DEPRECATED_NO_WARNINGS")
216+
STRING_APPEND(CMAKE_CXX_FLAGS " -D_WINSOCK_DEPRECATED_NO_WARNINGS")
216217

217-
#TODO: update the code and remove the disabled warnings
218+
# 'std::wbuffer_convert' is deprecated. Use MultiByteToWideChar
219+
STRING_APPEND(CMAKE_C_FLAGS " -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING")
220+
STRING_APPEND(CMAKE_CXX_FLAGS " -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING")
218221

219-
# The compiler encountered a deprecated declaration.
220-
STRING_APPEND(CMAKE_C_FLAGS " /wd4996")
221-
STRING_APPEND(CMAKE_CXX_FLAGS " /wd4996")
222+
# 'std::Header_strstream' is deprecated.
223+
STRING_APPEND(CMAKE_C_FLAGS " -D_SILENCE_CXX17_STRSTREAM_DEPRECATION_WARNING")
224+
STRING_APPEND(CMAKE_CXX_FLAGS " -D_SILENCE_CXX17_STRSTREAM_DEPRECATION_WARNING")
222225

223226
# 'var' : conversion from 'size_t' to 'type', possible loss of data
224227
STRING_APPEND(CMAKE_C_FLAGS " /wd4267")

extra/icu/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2017, 2022, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -114,6 +114,13 @@ IF(MSVC AND NOT WIN32_CLANG)
114114
STRING_APPEND(CMAKE_CXX_FLAGS " /utf-8")
115115
ENDIF()
116116

117+
#TODO(Bug#33986227): fix the deprecation for ICU
118+
IF(MSVC)
119+
STRING_APPEND(CMAKE_C_FLAGS " /wd4996")
120+
STRING_APPEND(CMAKE_CXX_FLAGS " /wd4996")
121+
ENDIF()
122+
123+
117124
IF(WITH_ICU STREQUAL "bundled")
118125
REMOVE_CMAKE_COMPILER_FLAGS(CMAKE_C_FLAGS "${MY_COMPILER_FLAG_FLTO}")
119126
REMOVE_CMAKE_COMPILER_FLAGS(CMAKE_CXX_FLAGS "${MY_COMPILER_FLAG_FLTO}")

extra/libevent/libevent-2.1.11-stable/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ IF(HAS_WARN_FLAG)
2929
STRING_APPEND(CMAKE_C_FLAGS " ${HAS_WARN_FLAG}")
3030
ENDIF()
3131

32+
#TODO(Bug#33986250): fix the deprecation for libevent
33+
IF(WIN32)
34+
STRING_APPEND(CMAKE_C_FLAGS " /wd4996")
35+
STRING_APPEND(CMAKE_CXX_FLAGS " /wd4996")
36+
ENDIF()
37+
38+
3239
# Don't do this here, it will load policies for an older version of cmake.
3340
# cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
3441

mysys/my_windac.cc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -34,16 +34,6 @@
3434

3535
/* Windows NT/2000 discretionary access control utility functions. */
3636

37-
/*
38-
Check if the operating system is built on NT technology.
39-
40-
RETURN
41-
0 Windows 95/98/Me
42-
1 otherwise
43-
*/
44-
45-
static bool is_nt() { return GetVersion() < 0x80000000; }
46-
4737
/*
4838
Auxilary structure to store pointers to the data which we need to keep
4939
around while SECURITY_ATTRIBUTES is in use.
@@ -95,11 +85,6 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
9585
PSID owner_sid;
9686
My_security_attr *attr;
9787

98-
if (!is_nt()) {
99-
*psa = 0;
100-
return 0;
101-
}
102-
10388
/*
10489
Get SID of Everyone group. Easier to retrieve all SIDs each time
10590
this function is called than worry about thread safety.

router/tests/component/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ MYSQL_ADD_EXECUTABLE(master_key_test_writer
3030
SKIP_INSTALL
3131
)
3232

33+
#TODO(Bug#33986295): fix the deprecation for router tests
34+
IF(MSVC)
35+
STRING_APPEND(CMAKE_C_FLAGS " /wd4996")
36+
STRING_APPEND(CMAKE_CXX_FLAGS " /wd4996")
37+
ENDIF()
38+
3339
ADD_DEFINITIONS(-DSSL_TEST_DATA_DIR="${CMAKE_SOURCE_DIR}/mysql-test/std_data/")
3440
ADD_DEFINITIONS(-DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
3541
FOREACH(test_file

sql/mysqld.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8289,7 +8289,7 @@ int mysqld_main(int argc, char **argv) {
82898289
}
82908290
}
82918291

8292-
if (Service.GetOS() && mysqld_monitor) /* true NT family */
8292+
if (mysqld_monitor) /* true NT family */
82938293
{
82948294
char file_path[FN_REFLEN];
82958295
my_path(file_path, argv[0], ""); /* Find name in path */

sql/nt_servc.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ static NTService *pService;
2424
2525
-------------------------------------------------------------------------- */
2626
NTService::NTService() {
27-
bOsNT = false;
2827
// service variables
2928
ServiceName = NULL;
3029
hExitEvent = 0;
@@ -65,16 +64,6 @@ NTService::~NTService() {
6564
6665
-------------------------------------------------------------------------- */
6766

68-
BOOL NTService::GetOS() {
69-
bOsNT = false;
70-
memset(&osVer, 0, sizeof(OSVERSIONINFO));
71-
osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
72-
if (GetVersionEx(&osVer)) {
73-
if (osVer.dwPlatformId == VER_PLATFORM_WIN32_NT) bOsNT = true;
74-
}
75-
return bOsNT;
76-
}
77-
7867
/**
7968
Registers the main service thread with the service manager.
8069

sql/nt_servc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class NTService {
2424
NTService();
2525
~NTService();
2626

27-
BOOL bOsNT; ///< true if OS is NT, false for Win95
2827
// install optinos
2928
DWORD dwDesiredAccess;
3029
DWORD dwServiceType;
@@ -34,7 +33,6 @@ class NTService {
3433
LPSTR szLoadOrderGroup;
3534
LPDWORD lpdwTagID;
3635
LPSTR szDependencies;
37-
OSVERSIONINFO osVer;
3836

3937
// time-out (in milisec)
4038
int nStartTimeOut;
@@ -49,8 +47,6 @@ class NTService {
4947
int nError;
5048
DWORD dwState;
5149

52-
BOOL GetOS(); // returns TRUE if WinNT
53-
BOOL IsNT() { return bOsNT; }
5450
// init service entry point
5551
long Init(LPCSTR szInternName, void *ServiceThread);
5652

0 commit comments

Comments
 (0)