diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-29 17:33:15 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-30 19:08:28 +0200 |
commit | c3609f107b16eb888edf284f4637be6cb09234eb (patch) | |
tree | da52e05b5cdf26d5d3a57f510f8b32d8af10a026 /configmgr | |
parent | 8a4df9376bf299beb49fe116882ffdbd10b5e02b (diff) |
Use SAL_W/SAL_U instead of reinterpret_cast btwn wchar_t* and sal_Unicode*
This is type-safe, and allows to catch cases where a source type
is changed for some reason, but reinterpret_cast masks that
Change-Id: Ib64b6fa2e22d94a6bba890f0ccc3e20325c6f0a1
Reviewed-on: https://gerrit.libreoffice.org/42961
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/winreg.cxx | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx index a60b345ee06e..bf30f8045d8f 100644 --- a/configmgr/source/winreg.cxx +++ b/configmgr/source/winreg.cxx @@ -86,7 +86,7 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil HKEY hCurKey; if(RegOpenKeyExW( - hKey, reinterpret_cast<wchar_t const *>(aKeyName.getStr()), 0, + hKey, SAL_W(aKeyName.getStr()), 0, KEY_READ, &hCurKey) == ERROR_SUCCESS) { @@ -109,13 +109,9 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil //Make up full key name if(aKeyName.isEmpty()) - aSubkeyName = aKeyName - + OUString( - reinterpret_cast<sal_Unicode const *>(buffKeyName)); + aSubkeyName = aKeyName + OUString(SAL_U(buffKeyName)); else - aSubkeyName = aKeyName + "\\" - + OUString( - reinterpret_cast<sal_Unicode const *>(buffKeyName)); + aSubkeyName = aKeyName + "\\" + OUString(SAL_U(buffKeyName)); //Recursion, until no more subkeys are found dumpWindowsRegistryKey(hKey, aSubkeyName, aFileHandle); @@ -126,8 +122,8 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil // No more subkeys, we are at a leaf auto pValueName = std::unique_ptr<wchar_t[]>( new wchar_t[nLongestValueNameLen + 1]); - auto pValue = std::unique_ptr<unsigned char[]>( - new unsigned char[(nLongestValueLen + 1) * sizeof (wchar_t)]); + auto pValue = std::unique_ptr<wchar_t[]>( + new wchar_t[nLongestValueLen/sizeof(wchar_t) + 1]); bool bFinal = false; OUString aValue; @@ -138,18 +134,16 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil DWORD nValueNameLen = nLongestValueNameLen + 1; DWORD nValueLen = nLongestValueLen + 1; - RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, pValue.get(), &nValueLen); + RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, reinterpret_cast<LPBYTE>(pValue.get()), &nValueLen); const wchar_t wsValue[] = L"Value"; const wchar_t wsFinal[] = L"Final"; const wchar_t wsType[] = L"Type"; if(!wcscmp(pValueName.get(), wsValue)) - aValue = OUString( - reinterpret_cast<sal_Unicode const *>(pValue.get())); - if (!wcscmp(pValueName.get(), wsType)) - aType = OUString( - reinterpret_cast<sal_Unicode const *>(pValue.get())); - if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1) + aValue = SAL_U(pValue.get()); + else if (!wcscmp(pValueName.get(), wsType)) + aType = SAL_U(pValue.get()); + else if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1) bFinal = true; } sal_Int32 aLastSeparator = aKeyName.lastIndexOf('\\'); |