Commit 53476abc authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Windows, compiling : use /permissive- switch to improve conformance

fix a couple "initialization skipped by goto" and other new errors.
parent 8fe04a3d
......@@ -148,6 +148,9 @@ IF(MSVC)
#TODO: update the code and remove the disabled warnings
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4700 /we4311 /we4477 /we4302 /we4090")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4099 /we4700 /we4311 /we4477 /we4302 /we4090")
IF(MSVC_VERSION GREATER 1910)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
ENDIF()
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS)
IF(MYSQL_MAINTAINER_MODE MATCHES "ERR")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
......
......@@ -72,6 +72,7 @@ void dump_single_process(DWORD pid)
char path[MAX_PATH];
char working_dir[MAX_PATH];
char tmpname[MAX_PATH];
char *filename= 0;
process= OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
if (!process)
......@@ -88,7 +89,7 @@ void dump_single_process(DWORD pid)
goto exit;
}
char *filename= strrchr(path, '\\');
filename= strrchr(path, '\\');
if (filename)
{
filename++;
......
......@@ -56,7 +56,7 @@ static int first_packet_len;
*/
char *srv_principal_name;
char *srv_keytab_path;
char *srv_mech_name=(char *)"";
const char *srv_mech_name="";
unsigned long srv_mech;
/**
......
......@@ -37,7 +37,7 @@ typedef enum
extern unsigned long srv_mech;
extern char *srv_principal_name;
extern char *srv_mech_name;
extern const char *srv_mech_name;
extern char *srv_keytab_path;
/*
Check, with GSSAPI/SSPI username of logged on user.
......
......@@ -163,7 +163,7 @@ int auth_server(MYSQL_PLUGIN_VIO *vio, const char *user, size_t user_len, int co
}
sspi_ret= AcquireCredentialsHandle(
srv_principal_name,
srv_mech_name,
(LPSTR)srv_mech_name,
SECPKG_CRED_INBOUND,
NULL,
NULL,
......@@ -287,7 +287,7 @@ int plugin_init()
ret = AcquireCredentialsHandle(
srv_principal_name,
srv_mech_name,
(LPSTR)srv_mech_name,
SECPKG_CRED_INBOUND,
NULL,
NULL,
......
......@@ -100,7 +100,7 @@ class Handshake
Handshake(const char *ssp, side_t side);
virtual ~Handshake();
int Handshake::packet_processing_loop();
int packet_processing_loop();
bool virtual is_complete() const
{
......
......@@ -333,6 +333,7 @@ IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
string(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ENDIF()
# Install some extra files that belong to connect engine
......
......@@ -84,7 +84,7 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
: XMLDOCUMENT(nsl, nsdf, enc)
{
assert (!fp || fp->Type == TYPE_FB_XML);
Docp = (fp) ? ((PXBLOCK)fp)->Docp : NULL;
Docp = (fp) ? ((PXBLOCK)fp)->Docp : (MSXML2::IXMLDOMDocumentPtr)NULL;
Nlist = NULL;
Hr = 0;
} // end of DOMDOC constructor
......
......@@ -814,7 +814,8 @@ os_file_get_block_size(
#ifdef _WIN32
fblock_size = 0;
BOOL result = false;
size_t len = 0;
// Open volume for this file, find out it "physical bytes per sector"
HANDLE volume_handle = INVALID_HANDLE_VALUE;
......@@ -825,7 +826,7 @@ os_file_get_block_size(
goto end;
}
size_t len = strlen(volume);
len = strlen(volume);
if (volume[len - 1] == '\\') {
// Trim trailing backslash from volume name.
volume[len - 1] = 0;
......@@ -849,7 +850,7 @@ os_file_get_block_size(
storage_query.PropertyId = StorageAccessAlignmentProperty;
storage_query.QueryType = PropertyStandardQuery;
BOOL result = os_win32_device_io_control(volume_handle,
result = os_win32_device_io_control(volume_handle,
IOCTL_STORAGE_QUERY_PROPERTY,
&storage_query,
sizeof(storage_query),
......
......@@ -148,13 +148,13 @@ sync_print_wait_info(FILE* file)
" %.2f RW-excl, %.2f RW-sx\n",
(double) rw_lock_stats.rw_s_spin_round_count /
(rw_lock_stats.rw_s_spin_wait_count
? rw_lock_stats.rw_s_spin_wait_count : 1),
? rw_lock_stats.rw_s_spin_wait_count : 1LL),
(double) rw_lock_stats.rw_x_spin_round_count /
(rw_lock_stats.rw_x_spin_wait_count
? rw_lock_stats.rw_x_spin_wait_count : 1),
? rw_lock_stats.rw_x_spin_wait_count : 1LL),
(double) rw_lock_stats.rw_sx_spin_round_count /
(rw_lock_stats.rw_sx_spin_wait_count
? rw_lock_stats.rw_sx_spin_wait_count : 1));
? rw_lock_stats.rw_sx_spin_wait_count : 1LL));
}
/**
......
......@@ -11,6 +11,7 @@ IF(MSVC)
ENDIF()
# Disable warning about deprecated functions, inet_aton
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
STRING(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
ENDIF()
IF(MSVC)
......
......@@ -60,13 +60,13 @@ extern "C" UINT __stdcall RemoveDataDirectory(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
wchar_t dir[MAX_PATH];
DWORD len = MAX_PATH;
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
wchar_t dir[MAX_PATH];
DWORD len = MAX_PATH;
MsiGetPropertyW(hInstall, L"CustomActionData", dir, &len);
er= ExecRemoveDataDirectory(dir);
......@@ -160,20 +160,21 @@ extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall,
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
wchar_t buf[MAX_PATH];
DWORD len = MAX_PATH;
WIN32_FIND_DATAW data;
HANDLE h;
bool empty;
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
wchar_t buf[MAX_PATH];
DWORD len = MAX_PATH;
MsiGetPropertyW(hInstall, PropertyName, buf, &len);
wcscat_s(buf, MAX_PATH, L"*.*");
WcaLog(LOGMSG_STANDARD, "Checking files in %S", buf);
WIN32_FIND_DATAW data;
HANDLE h;
bool empty;
h= FindFirstFile(buf, &data);
if (h != INVALID_HANDLE_VALUE)
{
......@@ -342,6 +343,12 @@ void CheckServiceConfig(
wchar_t * commandline= config->lpBinaryPathName;
int numargs;
wchar_t **argv= CommandLineToArgvW(commandline, &numargs);
wchar_t current_datadir_buf[MAX_PATH]={0};
wchar_t normalized_current_datadir[MAX_PATH+1];
wchar_t *current_datadir;
wchar_t *defaults_file;
bool is_my_service;
WcaLog(LOGMSG_VERBOSE, "CommandLine= %S", commandline);
if(!argv || !argv[0] || ! wcsstr(argv[0], L"mysqld"))
{
......@@ -356,7 +363,7 @@ void CheckServiceConfig(
same_bindir = true;
}
bool is_my_service = (_wcsicmp(my_servicename, other_servicename) == 0);
is_my_service = (_wcsicmp(my_servicename, other_servicename) == 0);
if(!is_my_service)
{
WcaLog(LOGMSG_STANDARD, "service does not match current service");
......@@ -379,10 +386,8 @@ void CheckServiceConfig(
goto end;
}
wchar_t current_datadir_buf[MAX_PATH]={0};
wchar_t normalized_current_datadir[MAX_PATH+1];
wchar_t *current_datadir= current_datadir_buf;
wchar_t *defaults_file= argv[1]+16;
current_datadir= current_datadir_buf;
defaults_file= argv[1]+16;
defaults_file= strip_quotes(defaults_file);
WcaLog(LOGMSG_STANDARD, "parsed defaults file is %S", defaults_file);
......@@ -453,6 +458,7 @@ extern "C" UINT CheckDBInUse(MSIHANDLE hInstall)
ULONG bufneed = 0x00;
ULONG num_services = 0x00;
LPENUM_SERVICE_STATUS_PROCESS info = NULL;
BOOL ok;
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
......@@ -471,7 +477,7 @@ extern "C" UINT CheckDBInUse(MSIHANDLE hInstall)
ExitOnFailure(E_FAIL, "OpenSCManager failed");
}
BOOL ok= EnumServicesStatusExW( scm,
ok = EnumServicesStatusExW( scm,
SC_ENUM_PROCESS_INFO,
SERVICE_WIN32,
SERVICE_STATE_ALL,
......@@ -559,13 +565,16 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
const wchar_t *ErrorMsg=0;
HRESULT hr= S_OK;
UINT er= ERROR_SUCCESS;
DWORD ServiceNameLen = MAX_PATH;
DWORD QuickConfigLen = MAX_PATH;
DWORD PasswordLen= MAX_PATH;
DWORD SkipNetworkingLen= MAX_PATH;
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
DWORD ServiceNameLen = MAX_PATH;
MsiGetPropertyW (hInstall, L"SERVICENAME", ServiceName, &ServiceNameLen);
if(ServiceName[0])
{
......@@ -594,13 +603,11 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
}
}
DWORD PasswordLen= MAX_PATH;
MsiGetPropertyW (hInstall, L"PASSWORD", Password, &PasswordLen);
EscapeCommandLine(Password, EscapedPassword,
sizeof(EscapedPassword)/sizeof(EscapedPassword[0]));
MsiSetPropertyW(hInstall,L"ESCAPEDPASSWORD",EscapedPassword);
DWORD SkipNetworkingLen= MAX_PATH;
MsiGetPropertyW(hInstall, L"SKIPNETWORKING", SkipNetworking,
&SkipNetworkingLen);
MsiGetPropertyW(hInstall, L"PORT", Port, &PortLen);
......@@ -644,8 +651,6 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
}
}
DWORD QuickConfigLen = MAX_PATH;
MsiGetPropertyW (hInstall, L"STDCONFIG", QuickConfig, &QuickConfigLen);
if(QuickConfig[0] !=0)
{
......@@ -722,12 +727,12 @@ extern "C" UINT __stdcall PresetDatabaseProperties(MSIHANDLE hInstall)
UINT er = ERROR_SUCCESS;
HRESULT hr= S_OK;
MEMORYSTATUSEX memstatus;
DWORD BufferPoolsizeParamLen = MAX_PATH;
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
/* Check if bufferpoolsize parameter was given on the command line*/
DWORD BufferPoolsizeParamLen = MAX_PATH;
MsiGetPropertyW(hInstall, L"BUFFERPOOLSIZE", buff, &BufferPoolsizeParamLen);
if (BufferPoolsizeParamLen && buff[0])
......@@ -817,11 +822,13 @@ extern "C" UINT __stdcall CreateDatabaseRollback(MSIHANDLE hInstall)
UINT er = ERROR_SUCCESS;
wchar_t* service= 0;
wchar_t* dir= 0;
wchar_t data[2*MAX_PATH];
DWORD len= MAX_PATH;
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
wchar_t data[2*MAX_PATH];
DWORD len= MAX_PATH;
MsiGetPropertyW(hInstall, L"CustomActionData", data, &len);
/* Property is encoded as [SERVICENAME]\[DBLOCATION] */
......@@ -871,6 +878,11 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
DWORD size =MAX_VERSION_PROPERTY_SIZE;
int installerMajorVersion, installerMinorVersion, installerPatchVersion;
bool upgradableServiceFound=false;
LPENUM_SERVICE_STATUS_PROCESSW info;
DWORD bufsize;
int index;
BOOL ok;
SC_HANDLE scm;
hr = WcaInitialize(hInstall, __FUNCTION__);
WcaLog(LOGMSG_STANDARD, "Initialized.");
......@@ -895,7 +907,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
}
SC_HANDLE scm = OpenSCManager(NULL, NULL,
scm = OpenSCManager(NULL, NULL,
SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
if (scm == NULL)
{
......@@ -906,19 +918,19 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
static BYTE buf[64*1024];
static BYTE config_buffer[8*1024];
DWORD bufsize= sizeof(buf);
bufsize= sizeof(buf);
DWORD bufneed;
DWORD num_services;
BOOL ok= EnumServicesStatusExW(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
ok= EnumServicesStatusExW(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
SERVICE_STATE_ALL, buf, bufsize, &bufneed, &num_services, NULL, NULL);
if(!ok)
{
hr = HRESULT_FROM_WIN32(GetLastError());
ExitOnFailure(hr,"EnumServicesStatusEx failed");
}
LPENUM_SERVICE_STATUS_PROCESSW info =
info =
(LPENUM_SERVICE_STATUS_PROCESSW)buf;
int index=-1;
index=-1;
for (ULONG i=0; i < num_services; i++)
{
SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
......@@ -928,7 +940,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
QUERY_SERVICE_CONFIGW *config=
(QUERY_SERVICE_CONFIGW*)(void *)config_buffer;
DWORD needed;
BOOL ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
&needed) && (config->dwStartType != SERVICE_DISABLED);
CloseServiceHandle(service);
if (ok)
......
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