Restore safe reinterpret_casts in misc Windows code

This commit is contained in:
Andrew Nelless 2016-09-12 13:32:50 +01:00
parent f1cd215f28
commit 5a03e37d15
1 changed files with 7 additions and 7 deletions

View File

@ -234,7 +234,7 @@ ArchMiscWindows::setValue(HKEY key,
return; return;
} }
RegSetValueEx(key, name, 0, REG_SZ, RegSetValueEx(key, name, 0, REG_SZ,
static_cast<const BYTE*>(value.c_str()), reinterpret_cast<const BYTE*>(value.c_str()),
(DWORD)value.size() + 1); (DWORD)value.size() + 1);
} }
@ -247,7 +247,7 @@ ArchMiscWindows::setValue(HKEY key, const TCHAR* name, DWORD value)
return; return;
} }
RegSetValueEx(key, name, 0, REG_DWORD, RegSetValueEx(key, name, 0, REG_DWORD,
static_cast<CONST BYTE*>(&value), reinterpret_cast<CONST BYTE*>(&value),
sizeof(DWORD)); sizeof(DWORD));
} }
@ -262,7 +262,7 @@ ArchMiscWindows::setValueBinary(HKEY key,
return; return;
} }
RegSetValueEx(key, name, 0, REG_BINARY, RegSetValueEx(key, name, 0, REG_BINARY,
static_cast<const BYTE*>(value.data()), reinterpret_cast<const BYTE*>(value.data()),
(DWORD)value.size()); (DWORD)value.size());
} }
@ -287,7 +287,7 @@ ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR* name, DWORD type)
// read it // read it
result = RegQueryValueEx(key, name, 0, &actualType, result = RegQueryValueEx(key, name, 0, &actualType,
static_cast<BYTE*>(buffer), &size); reinterpret_cast<BYTE*>(buffer), &size);
if (result != ERROR_SUCCESS || actualType != type) { if (result != ERROR_SUCCESS || actualType != type) {
delete[] buffer; delete[] buffer;
return std::string(); return std::string();
@ -322,7 +322,7 @@ ArchMiscWindows::readValueInt(HKEY key, const TCHAR* name)
DWORD value; DWORD value;
DWORD size = sizeof(value); DWORD size = sizeof(value);
LONG result = RegQueryValueEx(key, name, 0, &type, LONG result = RegQueryValueEx(key, name, 0, &type,
static_cast<BYTE*>(&value), &size); reinterpret_cast<BYTE*>(&value), &size);
if (result != ERROR_SUCCESS || type != REG_DWORD) { if (result != ERROR_SUCCESS || type != REG_DWORD) {
return 0; return 0;
} }
@ -374,7 +374,7 @@ ArchMiscWindows::setThreadExecutionState(DWORD busyModes)
if (s_stes == NULL) { if (s_stes == NULL) {
HINSTANCE kernel = LoadLibrary("kernel32.dll"); HINSTANCE kernel = LoadLibrary("kernel32.dll");
if (kernel != NULL) { if (kernel != NULL) {
s_stes = static_cast<STES_t>(GetProcAddress(kernel, s_stes = reinterpret_cast<STES_t>(GetProcAddress(kernel,
"SetThreadExecutionState")); "SetThreadExecutionState"));
} }
if (s_stes == NULL) { if (s_stes == NULL) {
@ -414,7 +414,7 @@ ArchMiscWindows::wakeupDisplay()
if (s_stes == NULL) { if (s_stes == NULL) {
HINSTANCE kernel = LoadLibrary("kernel32.dll"); HINSTANCE kernel = LoadLibrary("kernel32.dll");
if (kernel != NULL) { if (kernel != NULL) {
s_stes = static_cast<STES_t>(GetProcAddress(kernel, s_stes = reinterpret_cast<STES_t>(GetProcAddress(kernel,
"SetThreadExecutionState")); "SetThreadExecutionState"));
} }
if (s_stes == NULL) { if (s_stes == NULL) {