diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-08-29 08:31:08 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-08-30 06:26:44 +0000 |
commit | 64e6441d9c017663df134b1b02324295e0450baf (patch) | |
tree | d89cb4bed3fcfddacdc6896c36e0d1bfddc35034 /src/printsupport | |
parent | f9431f5632ca577a099bd4063f1412cff81f5f8d (diff) |
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 <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/printsupport')
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 5ee93a46b3..e3a5c3d2e8 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1556,14 +1556,15 @@ HGLOBAL *QWin32PrintEngine::createGlobalDevNames() Q_D(QWin32PrintEngine); int size = sizeof(DEVNAMES) + d->m_printDevice.id().length() * 2 + 2; - HGLOBAL *hGlobal = (HGLOBAL *) GlobalAlloc(GMEM_MOVEABLE, size); - DEVNAMES *dn = (DEVNAMES*) GlobalLock(hGlobal); + auto hGlobal = reinterpret_cast<HGLOBAL *>(GlobalAlloc(GMEM_MOVEABLE, size)); + auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(hGlobal)); dn->wDriverOffset = 0; dn->wDeviceOffset = sizeof(DEVNAMES) / sizeof(wchar_t); dn->wOutputOffset = 0; - memcpy((ushort*)dn + dn->wDeviceOffset, d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2); + memcpy(reinterpret_cast<ushort*>(dn) + dn->wDeviceOffset, + d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2); dn->wDefault = 0; GlobalUnlock(hGlobal); @@ -1574,8 +1575,9 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD { Q_D(QWin32PrintEngine); if (globalDevNames) { - DEVNAMES *dn = (DEVNAMES*) GlobalLock(globalDevNames); - QString id = QString::fromWCharArray((wchar_t*)(dn) + dn->wDeviceOffset); + auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(globalDevNames)); + const QString id = + QString::fromWCharArray(reinterpret_cast<const wchar_t*>(dn) + dn->wDeviceOffset); QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (ps) d->m_printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id); @@ -1583,7 +1585,7 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD } if (globalDevMode) { - DEVMODE *dm = (DEVMODE*) GlobalLock(globalDevMode); + auto dm = reinterpret_cast<DEVMODE*>(GlobalLock(globalDevMode)); d->release(); d->globalDevMode = globalDevMode; if (d->ownsDevMode) { |