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/printsupport/kernel/qprintengine_win.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/printsupport') 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(GlobalAlloc(GMEM_MOVEABLE, size)); + auto dn = reinterpret_cast(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(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(GlobalLock(globalDevNames)); + const QString id = + QString::fromWCharArray(reinterpret_cast(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(GlobalLock(globalDevMode)); d->release(); d->globalDevMode = globalDevMode; if (d->ownsDevMode) { -- cgit v1.2.3