Commit 282b6520 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent d995dd28
......@@ -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")
......
......@@ -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.
......
......@@ -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;
......
......@@ -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];
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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.
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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
......
......@@ -108,6 +108,9 @@ Rdb_sst_file_ordered::Rdb_sst_file::put(const rocksdb::Slice &key,
// Add the specified key/value to the sst file writer
#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);
}
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment