diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-02-07 20:17:38 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-02-07 20:17:38 +0000 |
commit | 282b652028ca79baa5a43aa5356d779a688947a8 (patch) | |
tree | 66205f73da3a22532dc0defa6132778e258ded8e | |
parent | d995dd2865b4dd5d01175594ed667cfe8ce41712 (diff) | |
download | mariadb-git-282b652028ca79baa5a43aa5356d779a688947a8.tar.gz |
Windows, compiling : reenable warning C4996 (deprecated functions)
But set _CRT_NONSTDC_NO_WARNINGS to silence silly warnings about
ANSI C function being non-standard
Remove now deprecated GetVersion()/GetVersionEx(),except single case
where where it is really needed, in feedback plugin. Remove checks for
Windows NT.
Avoid old IPv4-only inet_aton, which generated the warning.
-rw-r--r-- | cmake/os/Windows.cmake | 5 | ||||
-rw-r--r-- | mysys/my_windac.c | 21 | ||||
-rw-r--r-- | plugin/feedback/utils.cc | 3 | ||||
-rw-r--r-- | sql/hostname.cc | 50 | ||||
-rw-r--r-- | sql/mysql_install_db.cc | 23 | ||||
-rw-r--r-- | sql/mysqld.cc | 143 | ||||
-rw-r--r-- | sql/nt_servc.cc | 13 | ||||
-rw-r--r-- | sql/nt_servc.h | 2 | ||||
-rw-r--r-- | sql/sql_connect.cc | 2 | ||||
-rw-r--r-- | sql/udf_example.c | 4 | ||||
-rw-r--r-- | storage/connect/CMakeLists.txt | 1 | ||||
-rw-r--r-- | storage/rocksdb/rdb_sst_info.cc | 3 | ||||
-rw-r--r-- | storage/sphinx/CMakeLists.txt | 2 |
13 files changed, 94 insertions, 178 deletions
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index fef4bbe201e..8490cb3b1a9 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -146,8 +146,9 @@ IF(MSVC) ENDIF() #TODO: update the code and remove the disabled warnings - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /we4700 /we4311 /we4477 /we4302 /we4090") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4291 /wd4996 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4700 /we4311 /we4477 /we4302 /we4090") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4291 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") diff --git a/mysys/my_windac.c b/mysys/my_windac.c index 9b489759625..720bf3b4894 100644 --- a/mysys/my_windac.c +++ b/mysys/my_windac.c @@ -17,21 +17,6 @@ #include "m_string.h" #ifdef __WIN__ -/* Windows NT/2000 discretionary access control utility functions. */ - -/* - Check if the operating system is built on NT technology. - - RETURN - 0 Windows 95/98/Me - 1 otherwise -*/ - -static my_bool is_nt() -{ - return GetVersion() < 0x80000000; -} - /* Auxiliary structure to store pointers to the data which we need to keep around while SECURITY_ATTRIBUTES is in use. @@ -86,12 +71,6 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, PSID owner_sid; My_security_attr *attr; - if (! is_nt()) - { - *psa= 0; - return 0; - } - /* Get SID of Everyone group. Easier to retrieve all SIDs each time this function is called than worry about thread safety. diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index 09abbb2de23..87893924b38 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -92,6 +92,9 @@ static int uname(struct utsname *buf) { OSVERSIONINFOEX ver; ver.dwOSVersionInfoSize = (DWORD)sizeof(ver); +#ifdef _MSC_VER +#pragma warning (disable : 4996) +#endif if (!GetVersionEx((OSVERSIONINFO *)&ver)) return -1; diff --git a/sql/hostname.cc b/sql/hostname.cc index 56bd407f1dd..92888b737b4 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -701,13 +701,11 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage, static struct addrinfo debug_addr_info[2]; /* Simulating ipv4 192.0.2.126 */ debug_addr= & debug_sock_addr[0]; - debug_addr->sin_family= AF_INET; - debug_addr->sin_addr.s_addr= inet_addr("192.0.2.126"); + inet_pton(AF_INET,"192.0.2.126",debug_addr); /* Simulating ipv4 192.0.2.127 */ debug_addr= & debug_sock_addr[1]; - debug_addr->sin_family= AF_INET; - debug_addr->sin_addr.s_addr= inet_addr("192.0.2.127"); + inet_pton(AF_INET,"192.0.2.127",debug_addr); debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0]; debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in); @@ -733,13 +731,11 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage, static struct addrinfo debug_addr_info[2]; /* Simulating ipv4 192.0.2.5 */ debug_addr= & debug_sock_addr[0]; - debug_addr->sin_family= AF_INET; - debug_addr->sin_addr.s_addr= inet_addr("192.0.2.5"); + inet_pton(AF_INET,"192.0.2.5",debug_addr); /* Simulating ipv4 192.0.2.4 */ debug_addr= & debug_sock_addr[1]; - debug_addr->sin_family= AF_INET; - debug_addr->sin_addr.s_addr= inet_addr("192.0.2.4"); + inet_pton(AF_INET,"192.0.2.5",debug_addr); debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0]; debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in); @@ -772,47 +768,13 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage, static struct addrinfo debug_addr_info[2]; /* Simulating ipv6 2001:DB8::6:7E */ debug_addr= & debug_sock_addr[0]; - debug_addr->sin6_family= AF_INET6; ip6= & debug_addr->sin6_addr; - /* inet_pton not available on Windows XP. */ - ip6->s6_addr[ 0] = 0x20; - ip6->s6_addr[ 1] = 0x01; - ip6->s6_addr[ 2] = 0x0d; - ip6->s6_addr[ 3] = 0xb8; - ip6->s6_addr[ 4] = 0x00; - ip6->s6_addr[ 5] = 0x00; - ip6->s6_addr[ 6] = 0x00; - ip6->s6_addr[ 7] = 0x00; - ip6->s6_addr[ 8] = 0x00; - ip6->s6_addr[ 9] = 0x00; - ip6->s6_addr[10] = 0x00; - ip6->s6_addr[11] = 0x00; - ip6->s6_addr[12] = 0x00; - ip6->s6_addr[13] = 0x06; - ip6->s6_addr[14] = 0x00; - ip6->s6_addr[15] = 0x7e; + inet_pton(AF_INET6,"2001:DB8::6:7E",ip6); /* Simulating ipv6 2001:DB8::6:7F */ debug_addr= & debug_sock_addr[1]; - debug_addr->sin6_family= AF_INET6; ip6= & debug_addr->sin6_addr; - ip6->s6_addr[ 0] = 0x20; - ip6->s6_addr[ 1] = 0x01; - ip6->s6_addr[ 2] = 0x0d; - ip6->s6_addr[ 3] = 0xb8; - ip6->s6_addr[ 4] = 0x00; - ip6->s6_addr[ 5] = 0x00; - ip6->s6_addr[ 6] = 0x00; - ip6->s6_addr[ 7] = 0x00; - ip6->s6_addr[ 8] = 0x00; - ip6->s6_addr[ 9] = 0x00; - ip6->s6_addr[10] = 0x00; - ip6->s6_addr[11] = 0x00; - ip6->s6_addr[12] = 0x00; - ip6->s6_addr[13] = 0x06; - ip6->s6_addr[14] = 0x00; - ip6->s6_addr[15] = 0x7f; - + inet_pton(AF_INET6,"2001:DB8::6:7E",ip6); debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0]; debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6); debug_addr_info[0].ai_next= & debug_addr_info[1]; diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 30f2d4f6526..b4af5cc79ed 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -524,28 +524,6 @@ static int set_directory_permissions(const char *dir, const char *os_user) } -/* - Give directory permissions for special service user NT SERVICE\servicename - this user is available only on Win7 and later. -*/ - -void grant_directory_permissions_to_service() -{ - char service_user[MAX_PATH+ 12]; - OSVERSIONINFO info; - info.dwOSVersionInfoSize= sizeof(info); - GetVersionEx(&info); - if (info.dwMajorVersion >6 || - (info.dwMajorVersion== 6 && info.dwMinorVersion > 0) - && opt_service) - { - my_snprintf(service_user,sizeof(service_user), "NT SERVICE\\%s", - opt_service); - set_directory_permissions(opt_datadir, service_user); - } -} - - /* Create database instance (including registering as service etc) .*/ static int create_db_instance() @@ -668,7 +646,6 @@ static int create_db_instance() if (opt_service && opt_service[0]) { ret= register_service(); - grant_directory_permissions_to_service(); if (ret) goto end; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 15353e4729a..1b76483c7eb 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2738,7 +2738,7 @@ static void network_init(void) #ifdef _WIN32 /* create named pipe */ - if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap && + if (mysqld_unix_port[0] && !opt_bootstrap && opt_enable_named_pipe) { @@ -6162,7 +6162,7 @@ int mysqld_main(int argc, char **argv) mysql_mutex_unlock(&LOCK_thread_count); #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) - if (Service.IsNT() && start_mode) + if (start_mode) Service.Stop(); else { @@ -6305,87 +6305,86 @@ int mysqld_main(int argc, char **argv) return 1; } - if (Service.GetOS()) /* true NT family */ + + char file_path[FN_REFLEN]; + my_path(file_path, argv[0], ""); /* Find name in path */ + fn_format(file_path,argv[0],file_path,"", MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS); + + if (argc == 2) { - char file_path[FN_REFLEN]; - my_path(file_path, argv[0], ""); /* Find name in path */ - fn_format(file_path,argv[0],file_path,"", - MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS); + if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, + file_path, "", NULL)) + return 0; - if (argc == 2) - { - if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, - file_path, "", NULL)) - return 0; - if (Service.IsService(argv[1])) /* Start an optional service */ - { - /* - Only add the service name to the groups read from the config file - if it's not "MySQL". (The default service name should be 'mysqld' - but we started a bad tradition by calling it MySQL from the start - and we are now stuck with it. - */ - if (my_strcasecmp(system_charset_info, argv[1],"mysql")) - load_default_groups[load_default_groups_sz-2]= argv[1]; - start_mode= 1; - Service.Init(argv[1], mysql_service); - return 0; - } - } - else if (argc == 3) /* install or remove any optional service */ - { - if (!default_service_handling(argv, argv[2], argv[2], file_path, "", - NULL)) - return 0; - if (Service.IsService(argv[2])) - { - /* - mysqld was started as - mysqld --defaults-file=my_path\my.ini service-name - */ - use_opt_args=1; - opt_argc= 2; // Skip service-name - opt_argv=argv; - start_mode= 1; - if (my_strcasecmp(system_charset_info, argv[2],"mysql")) - load_default_groups[load_default_groups_sz-2]= argv[2]; - Service.Init(argv[2], mysql_service); - return 0; - } - } - else if (argc == 4 || argc == 5) + if (Service.IsService(argv[1])) /* Start an optional service */ { /* - This may seem strange, because we handle --local-service while - preserving 4.1's behavior of allowing any one other argument that is - passed to the service on startup. (The assumption is that this is - --defaults-file=file, but that was not enforced in 4.1, so we don't - enforce it here.) + Only add the service name to the groups read from the config file + if it's not "MySQL". (The default service name should be 'mysqld' + but we started a bad tradition by calling it MySQL from the start + and we are now stuck with it. */ - const char *extra_opt= NullS; - const char *account_name = NullS; - int index; - for (index = 3; index < argc; index++) - { - if (!strcmp(argv[index], "--local-service")) - account_name= "NT AUTHORITY\\LocalService"; - else - extra_opt= argv[index]; - } - - if (argc == 4 || account_name) - if (!default_service_handling(argv, argv[2], argv[2], file_path, - extra_opt, account_name)) - return 0; + if (my_strcasecmp(system_charset_info, argv[1],"mysql")) + load_default_groups[load_default_groups_sz-2]= argv[1]; + start_mode= 1; + Service.Init(argv[1], mysql_service); + return 0; } - else if (argc == 1 && Service.IsService(MYSQL_SERVICENAME)) + } + else if (argc == 3) /* install or remove any optional service */ + { + if (!default_service_handling(argv, argv[2], argv[2], file_path, "", + NULL)) + return 0; + if (Service.IsService(argv[2])) { - /* start the default service */ + /* + mysqld was started as + mysqld --defaults-file=my_path\my.ini service-name + */ + use_opt_args=1; + opt_argc= 2; // Skip service-name + opt_argv=argv; start_mode= 1; - Service.Init(MYSQL_SERVICENAME, mysql_service); + if (my_strcasecmp(system_charset_info, argv[2],"mysql")) + load_default_groups[load_default_groups_sz-2]= argv[2]; + Service.Init(argv[2], mysql_service); return 0; } } + else if (argc == 4 || argc == 5) + { + /* + This may seem strange, because we handle --local-service while + preserving 4.1's behavior of allowing any one other argument that is + passed to the service on startup. (The assumption is that this is + --defaults-file=file, but that was not enforced in 4.1, so we don't + enforce it here.) + */ + const char *extra_opt= NullS; + const char *account_name = NullS; + int index; + for (index = 3; index < argc; index++) + { + if (!strcmp(argv[index], "--local-service")) + account_name= "NT AUTHORITY\\LocalService"; + else + extra_opt= argv[index]; + } + + if (argc == 4 || account_name) + if (!default_service_handling(argv, argv[2], argv[2], file_path, + extra_opt, account_name)) + return 0; + } + else if (argc == 1 && Service.IsService(MYSQL_SERVICENAME)) + { + /* start the default service */ + start_mode= 1; + Service.Init(MYSQL_SERVICENAME, mysql_service); + return 0; + } + /* Start as standalone server */ Service.my_argc=argc; Service.my_argv=argv; diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index e05e43a0a59..654383c3320 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -64,19 +64,6 @@ NTService::~NTService() -------------------------------------------------------------------------- */ -BOOL NTService::GetOS() -{ - bOsNT = FALSE; - memset(&osVer, 0, sizeof(OSVERSIONINFO)); - osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (GetVersionEx(&osVer)) - { - if (osVer.dwPlatformId == VER_PLATFORM_WIN32_NT) - bOsNT = TRUE; - } - return bOsNT; -} - /** Registers the main service thread with the service manager. diff --git a/sql/nt_servc.h b/sql/nt_servc.h index 6781fe0ddfa..c8b64515b31 100644 --- a/sql/nt_servc.h +++ b/sql/nt_servc.h @@ -45,8 +45,6 @@ class NTService int nError; DWORD dwState; - BOOL GetOS(); // returns TRUE if WinNT - BOOL IsNT() { return bOsNT;} //init service entry point long Init(LPCSTR szInternName,void *ServiceThread); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 7ac8bc7cadd..81beb5d4110 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -979,7 +979,7 @@ static int check_connection(THD *thd) struct in_addr *ip4= &((struct sockaddr_in *) sa)->sin_addr; /* See RFC 5737, 192.0.2.0/24 is reserved. */ const char* fake= "192.0.2.4"; - ip4->s_addr= inet_addr(fake); + inet_pton(AF_INET,fake, &ip4); strcpy(ip, fake); peer_rc= 0; } diff --git a/sql/udf_example.c b/sql/udf_example.c index cc9a703373c..afe3c5592bc 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -142,6 +142,10 @@ typedef long long longlong; #ifdef _WIN32 /* inet_aton needs winsock library */ #pragma comment(lib, "ws2_32") +#if _MSC_VER +/* Silence warning about deprecated functions , gethostbyname etc*/ +#pragma warning(disable : 4996) +#endif #endif #ifdef HAVE_DLOPEN diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 7e900e55368..3185aa8ea4e 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -332,6 +332,7 @@ IF(MSVC) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") ENDIF() # Install some extra files that belong to connect engine diff --git a/storage/rocksdb/rdb_sst_info.cc b/storage/rocksdb/rdb_sst_info.cc index da3a3d94354..70f19c6af11 100644 --- a/storage/rocksdb/rdb_sst_info.cc +++ b/storage/rocksdb/rdb_sst_info.cc @@ -109,6 +109,9 @@ Rdb_sst_file_ordered::Rdb_sst_file::put(const rocksdb::Slice &key, #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif +#ifdef _MSC_VER +#pragma warning (disable : 4996) +#endif return m_sst_file_writer->Add(key, value); } diff --git a/storage/sphinx/CMakeLists.txt b/storage/sphinx/CMakeLists.txt index f05da9a496f..71130080e24 100644 --- a/storage/sphinx/CMakeLists.txt +++ b/storage/sphinx/CMakeLists.txt @@ -9,6 +9,8 @@ IF(MSVC) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") ENDIF() + # Disable warning about deprecated functions, inet_aton + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") ENDIF() IF(MSVC) |