diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-18 11:22:17 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-18 12:22:10 +0000 |
commit | 05eef60ec3758b4c4d9f3c1cac5f31f7c40d0c4b (patch) | |
tree | 4db16a54c2d2509c21da76c396b68024deba2751 | |
parent | 25a33686ff370c70dbf4220b1bca618c057953cf (diff) | |
download | qttools-05eef60ec3758b4c4d9f3c1cac5f31f7c40d0c4b.tar.gz |
windeployqt: Fix some CLANG warnings.
Remove C-style casts, fix integer conversion issues and remove
unused variables.
Change-Id: Ice842f0eab256c33d8c84b046118ce6930d19b70
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | src/windeployqt/elfreader.cpp | 12 | ||||
-rw-r--r-- | src/windeployqt/main.cpp | 9 | ||||
-rw-r--r-- | src/windeployqt/utils.cpp | 18 |
3 files changed, 19 insertions, 20 deletions
diff --git a/src/windeployqt/elfreader.cpp b/src/windeployqt/elfreader.cpp index af9484002..4b9cc4838 100644 --- a/src/windeployqt/elfreader.cpp +++ b/src/windeployqt/elfreader.cpp @@ -90,7 +90,7 @@ static void parseSectionHeader(const uchar *s, ElfSectionHeader *sh, const ElfDa { sh->index = getWord(s, context); sh->type = getWord(s, context); - sh->flags = getOffset(s, context); + sh->flags = quint32(getOffset(s, context)); sh->addr = getAddress(s, context); sh->offset = getOffset(s, context); sh->size = getOffset(s, context); @@ -116,13 +116,13 @@ public: if (!file.open(QIODevice::ReadOnly)) return false; - fdlen = file.size(); - ustart = file.map(0, fdlen); + fdlen = quint64(file.size()); + ustart = file.map(0, qint64(fdlen)); if (ustart == 0) { // Try reading the data into memory instead. raw = file.readAll(); start = raw.constData(); - fdlen = raw.size(); + fdlen = quint64(raw.size()); } return true; } @@ -290,7 +290,7 @@ ElfReader::Result ElfReader::readIt() m_elfData.symbolsType = BuildIdSymbols; if (sh.size > 16) m_elfData.buildId = QByteArray(mapper.start + sh.offset + 16, - sh.size - 16).toHex(); + int(sh.size) - 16).toHex(); } m_elfData.sectionHeaders.append(sh); } @@ -319,7 +319,7 @@ QByteArray ElfReader::readSection(const QByteArray &name) return QByteArray(); const ElfSectionHeader §ion = m_elfData.sectionHeaders.at(i); - return QByteArray(mapper.start + section.offset, section.size); + return QByteArray(mapper.start + section.offset, int(section.size)); } static QByteArray cutout(const char *s) diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp index 717af4ee6..d6a06c47b 100644 --- a/src/windeployqt/main.cpp +++ b/src/windeployqt/main.cpp @@ -113,7 +113,7 @@ struct QtModuleEntry { const char *translation; }; -QtModuleEntry qtModuleEntries[] = { +static QtModuleEntry qtModuleEntries[] = { { QtBluetoothModule, "bluetooth", "Qt5Bluetooth", 0 }, { QtCLuceneModule, "clucene", "Qt5CLucene", "qt_help" }, { QtConcurrentModule, "concurrent", "Qt5Concurrent", "qtbase" }, @@ -234,8 +234,7 @@ static ExlusiveOptionValue parseExclusiveOptions(const QCommandLineParser *parse return disabled ? OptionDisabled : OptionAuto; } -bool optHelp = false; -ExlusiveOptionValue optWebKit2 = OptionAuto; +static ExlusiveOptionValue optWebKit2 = OptionAuto; struct Options { enum DebugDetection { @@ -268,7 +267,7 @@ struct Options { Platform platform; quint64 additionalLibraries; quint64 disabledLibraries; - quint64 updateFileFlags; + unsigned updateFileFlags; QStringList qmlDirectories; // Project's QML files. QString directory; QString translationsDirectory; // Translations target directory @@ -1409,7 +1408,7 @@ static DeployResult deploy(const Options &options, << QDir::toNativeSeparators(installPath) << '\n'; if (installPath != options.directory && !createDirectory(installPath, errorMessage)) return result; - quint64 updateFileFlags = options.updateFileFlags | SkipQmlDesignerSpecificsDirectories; + unsigned updateFileFlags = options.updateFileFlags | SkipQmlDesignerSpecificsDirectories; unsigned qmlDirectoryFileFlags = 0; if (quickControlsImportPath(module.sourcePath) == 1) { // QML files of Controls 1 not needed updateFileFlags |= RemoveEmptyQmlDirectories; diff --git a/src/windeployqt/utils.cpp b/src/windeployqt/utils.cpp index 7dfb52184..64f39619d 100644 --- a/src/windeployqt/utils.cpp +++ b/src/windeployqt/utils.cpp @@ -147,11 +147,11 @@ QString winErrorMessage(unsigned long error) QString rc = QString::fromLatin1("#%1: ").arg(error); ushort *lpMsgBuf; - const int len = FormatMessage( + const DWORD len = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL); + NULL, error, 0, reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, NULL); if (len) { - rc = QString::fromUtf16(lpMsgBuf, len); + rc = QString::fromUtf16(lpMsgBuf, int(len)); LocalFree(lpMsgBuf); } else { rc += QString::fromLatin1("<unknown error>"); @@ -164,7 +164,7 @@ QString normalizeFileName(const QString &name) { wchar_t shortBuffer[MAX_PATH]; const QString nativeFileName = QDir::toNativeSeparators(name); - if (!GetShortPathNameW((wchar_t *)nativeFileName.utf16(), shortBuffer, MAX_PATH)) + if (!GetShortPathNameW(reinterpret_cast<LPCWSTR>(nativeFileName.utf16()), shortBuffer, MAX_PATH)) return name; wchar_t result[MAX_PATH]; if (!GetLongPathNameW(shortBuffer, result, MAX_PATH)) @@ -208,7 +208,7 @@ static inline void readTemporaryProcessFile(HANDLE handle, QByteArray *result) char buf[1024]; DWORD bytesRead; while (ReadFile(handle, buf, sizeof(buf), &bytesRead, NULL) && bytesRead) - result->append(buf, bytesRead); + result->append(buf, int(bytesRead)); CloseHandle(handle); } @@ -283,7 +283,7 @@ bool runProcess(const QString &binary, const QStringList &args, commandLine.toWCharArray(commandLineW.data()); commandLineW[commandLine.size()] = 0; if (!CreateProcessW(0, commandLineW.data(), 0, 0, /* InheritHandles */ TRUE, 0, 0, - (wchar_t *)nativeWorkingDir.utf16(), &si, &pi)) { + reinterpret_cast<LPCWSTR>(nativeWorkingDir.utf16()), &si, &pi)) { if (stdOut) CloseHandle(si.hStdOutput); if (stdErr) @@ -642,7 +642,7 @@ bool readElfExecutable(const QString &elfExecutableFileName, QString *errorMessa static inline QString stringFromRvaPtr(const void *rvaPtr) { - return QString::fromLocal8Bit((const char *)rvaPtr); + return QString::fromLocal8Bit(static_cast<const char *>(rvaPtr)); } // Helper for reading out PE executable files: Find a section header for an RVA @@ -729,7 +729,7 @@ inline QStringList readImportSections(const ImageNtHeader *ntHeaders, const void *errorMessage = QString::fromLatin1("Failed to find IMAGE_DIRECTORY_ENTRY_IMPORT entry."); return QStringList(); } - const IMAGE_IMPORT_DESCRIPTOR *importDesc = (const IMAGE_IMPORT_DESCRIPTOR *)rvaToPtr(importsStartRVA, ntHeaders, base); + const IMAGE_IMPORT_DESCRIPTOR *importDesc = static_cast<const IMAGE_IMPORT_DESCRIPTOR *>(rvaToPtr(importsStartRVA, ntHeaders, base)); if (!importDesc) { *errorMessage = QString::fromLatin1("Failed to find IMAGE_IMPORT_DESCRIPTOR entry."); return QStringList(); @@ -741,7 +741,7 @@ inline QStringList readImportSections(const ImageNtHeader *ntHeaders, const void // Read delay-loaded DLLs, see http://msdn.microsoft.com/en-us/magazine/cc301808.aspx . // Check on grAttr bit 1 whether this is the format using RVA's > VS 6 if (const DWORD delayedImportsStartRVA = ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress) { - const ImgDelayDescr *delayedImportDesc = (const ImgDelayDescr *)rvaToPtr(delayedImportsStartRVA, ntHeaders, base); + const ImgDelayDescr *delayedImportDesc = static_cast<const ImgDelayDescr *>(rvaToPtr(delayedImportsStartRVA, ntHeaders, base)); for ( ; delayedImportDesc->rvaDLLName && (delayedImportDesc->grAttrs & 1); ++delayedImportDesc) result.push_back(stringFromRvaPtr(rvaToPtr(delayedImportDesc->rvaDLLName, ntHeaders, base))); } |