From 64e6441d9c017663df134b1b02324295e0450baf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 Aug 2018 08:31:08 +0200 Subject: Windows code: Fix clang-tidy warnings about C-style casts Replace by reinterpret_cast or const_cast, respectively. Use auto when initializing a variable to fix Clang warnings about repeating the type name, do minor tidying along the way, and a few conversions of 0 or NULL to nullptr. Change-Id: Ieb271a87ddcf064f536e1ff05d23b1e688b1b56a Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_win.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/corelib/tools/qtimezoneprivate_win.cpp') diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp index ec91b7e8a8..ca7ea24fc5 100644 --- a/src/corelib/tools/qtimezoneprivate_win.cpp +++ b/src/corelib/tools/qtimezoneprivate_win.cpp @@ -140,15 +140,15 @@ bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMATION &tz #ifdef QT_USE_REGISTRY_TIMEZONE bool openRegistryKey(const QString &keyPath, HKEY *key) { - return (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (const wchar_t*)keyPath.utf16(), 0, KEY_READ, key) - == ERROR_SUCCESS); + return RegOpenKeyEx(HKEY_LOCAL_MACHINE, reinterpret_cast(keyPath.utf16()), + 0, KEY_READ, key) == ERROR_SUCCESS; } QString readRegistryString(const HKEY &key, const wchar_t *value) { wchar_t buffer[MAX_PATH] = {0}; DWORD size = sizeof(wchar_t) * MAX_PATH; - RegQueryValueEx(key, (LPCWSTR)value, NULL, NULL, (LPBYTE)buffer, &size); + RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast(buffer), &size); return QString::fromWCharArray(buffer); } @@ -156,7 +156,7 @@ int readRegistryValue(const HKEY &key, const wchar_t *value) { DWORD buffer; DWORD size = sizeof(buffer); - RegQueryValueEx(key, (LPCWSTR)value, NULL, NULL, (LPBYTE)&buffer, &size); + RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast(&buffer), &size); return buffer; } @@ -167,7 +167,7 @@ QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key, QWinTimeZonePrivate::QWinTransitionRule rule; REG_TZI_FORMAT tzi; DWORD tziSize = sizeof(tzi); - if (RegQueryValueEx(key, (LPCWSTR)value, NULL, NULL, (BYTE *)&tzi, &tziSize) + if (RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast(&tzi), &tziSize) == ERROR_SUCCESS) { rule.startYear = 0; rule.standardTimeBias = tzi.Bias + tzi.StandardBias; @@ -192,12 +192,12 @@ TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok) if (openRegistryKey(tziKeyPath, &key)) { DWORD size = sizeof(tzi.DaylightName); - RegQueryValueEx(key, L"Dlt", NULL, NULL, (LPBYTE)tzi.DaylightName, &size); + RegQueryValueEx(key, L"Dlt", nullptr, nullptr, reinterpret_cast(tzi.DaylightName), &size); size = sizeof(tzi.StandardName); - RegQueryValueEx(key, L"Std", NULL, NULL, (LPBYTE)tzi.StandardName, &size); + RegQueryValueEx(key, L"Std", nullptr, nullptr, reinterpret_cast(tzi.StandardName), &size); - if (RegQueryValueEx(key, L"TZI", NULL, NULL, (BYTE *) ®Tzi, ®TziSize) + if (RegQueryValueEx(key, L"TZI", nullptr, nullptr, reinterpret_cast(®Tzi), ®TziSize) == ERROR_SUCCESS) { tzi.Bias = regTzi.Bias; tzi.StandardBias = regTzi.StandardBias; @@ -590,7 +590,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId) for (int year = startYear; year <= endYear; ++year) { bool ruleOk; QWinTransitionRule rule = readRegistryRule(dynamicKey, - (LPCWSTR)QString::number(year).utf16(), + reinterpret_cast(QString::number(year).utf16()), &ruleOk); if (ruleOk // Don't repeat a recurrent rule: -- cgit v1.2.3