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/corelib/io/qfilesystemengine_win.cpp | |
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/corelib/io/qfilesystemengine_win.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index fadc058110..74081b4ffa 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -935,7 +935,7 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData & bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { - HANDLE fHandle = (HANDLE)_get_osfhandle(fd); + auto fHandle = reinterpret_cast<HANDLE>(_get_osfhandle(fd)); if (fHandle != INVALID_HANDLE_VALUE) { return fillMetaData(fHandle, data, what); } @@ -1014,7 +1014,8 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM WIN32_FIND_DATA findData; // The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA // for all members used by fillFindData(). - bool ok = ::GetFileAttributesEx((wchar_t*)fname.nativeFilePath().utf16(), GetFileExInfoStandard, + bool ok = ::GetFileAttributesEx(reinterpret_cast<const wchar_t*>(fname.nativeFilePath().utf16()), + GetFileExInfoStandard, reinterpret_cast<WIN32_FILE_ATTRIBUTE_DATA *>(&findData)); if (ok) { data.fillFromFindData(findData, false, fname.isDriveRoot()); @@ -1069,19 +1070,22 @@ static bool isDirPath(const QString &dirPath, bool *existed) if (path.length() == 2 && path.at(1) == QLatin1Char(':')) path += QLatin1Char('\\'); + const QString longPath = QFSFileEnginePrivate::longFileName(path); #ifndef Q_OS_WINRT - DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); + DWORD fileAttrib = ::GetFileAttributes(reinterpret_cast<const wchar_t*>(longPath.utf16())); #else // Q_OS_WINRT DWORD fileAttrib = INVALID_FILE_ATTRIBUTES; WIN32_FILE_ATTRIBUTE_DATA data; - if (::GetFileAttributesEx((const wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), GetFileExInfoStandard, &data)) + if (::GetFileAttributesEx(reinterpret_cast<const wchar_t*>(longPath.utf16()), + GetFileExInfoStandard, &data)) { fileAttrib = data.dwFileAttributes; + } #endif // Q_OS_WINRT if (fileAttrib == INVALID_FILE_ATTRIBUTES) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { WIN32_FIND_DATA findData; - if (getFindData(QFSFileEnginePrivate::longFileName(path), findData)) + if (getFindData(longPath, findData)) fileAttrib = findData.dwFileAttributes; } } @@ -1411,7 +1415,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per if (mode == 0) // not supported return false; - bool ret = (::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0); + bool ret = ::_wchmod(reinterpret_cast<const wchar_t*>(entry.nativeFilePath().utf16()), mode) == 0; if(!ret) error = QSystemError(errno, QSystemError::StandardLibraryError); return ret; |