From 7fe94ca7b4aa191b1e79331b16724b7e9cc9f56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 28 Jun 2018 23:18:45 +0200 Subject: [PATCH] NOISSUE fix all sorts of warnings, enable `Werror` and `pedantic` --- CMakeLists.txt | 2 +- api/gui/DesktopServices.h | 2 +- api/logic/Version.h | 3 +- api/logic/meta/JsonFormat.h | 2 +- api/logic/minecraft/Component.cpp | 4 +- api/logic/minecraft/Library.cpp | 8 ++-- api/logic/minecraft/MinecraftInstance.h | 2 +- api/logic/minecraft/World.cpp | 4 +- api/logic/minecraft/launch/ModMinecraftJar.h | 4 +- .../modplatform/ftb/FtbPackInstallTask.cpp | 2 +- api/logic/net/FileSink.cpp | 4 +- api/logic/net/MetaCacheSink.cpp | 4 +- api/logic/updater/GoUpdate.h | 2 +- application/VersionProxyModel.cpp | 2 +- application/pages/BasePageProvider.h | 1 + application/setupwizard/AnalyticsWizardPage.h | 2 +- application/setupwizard/JavaWizardPage.h | 2 +- application/setupwizard/LanguageWizardPage.h | 2 +- libraries/classparser/src/constants.h | 38 ++++++++++--------- libraries/classparser/src/javaendian.h | 12 +++--- libraries/iconfix/xdgicon.cpp | 2 +- 21 files changed, 55 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72d75a99..c85eb9ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ set(CMAKE_C_STANDARD_REQUIRED true) set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_STANDARD 11) include(GenerateExportHeader) -set(CMAKE_CXX_FLAGS " -Wall -D_GLIBCXX_USE_CXX11_ABI=0 ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS " -Wall -pedantic -Werror -D_GLIBCXX_USE_CXX11_ABI=0 ${CMAKE_CXX_FLAGS}") if(UNIX AND APPLE) set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}") endif() diff --git a/api/gui/DesktopServices.h b/api/gui/DesktopServices.h index 9daf192a..f64a62c5 100644 --- a/api/gui/DesktopServices.h +++ b/api/gui/DesktopServices.h @@ -34,4 +34,4 @@ namespace DesktopServices * Open the URL, most likely in a browser. Maybe. */ MULTIMC_GUI_EXPORT bool openUrl(const QUrl &url); -}; +} diff --git a/api/logic/Version.h b/api/logic/Version.h index 08dfb6e9..7aa2ebe8 100644 --- a/api/logic/Version.h +++ b/api/logic/Version.h @@ -7,8 +7,9 @@ class QUrl; -struct MULTIMC_LOGIC_EXPORT Version +class MULTIMC_LOGIC_EXPORT Version { +public: Version(const QString &str); Version() {} diff --git a/api/logic/meta/JsonFormat.h b/api/logic/meta/JsonFormat.h index 762a36f6..cc2c8f83 100644 --- a/api/logic/meta/JsonFormat.h +++ b/api/logic/meta/JsonFormat.h @@ -80,4 +80,4 @@ void serializeRequires(QJsonObject & objOut, RequireSet* ptr, const char * keyNa MetadataVersion currentFormatVersion(); } -Q_DECLARE_METATYPE(std::set); \ No newline at end of file +Q_DECLARE_METATYPE(std::set) diff --git a/api/logic/minecraft/Component.cpp b/api/logic/minecraft/Component.cpp index c6e41e65..7c52271e 100644 --- a/api/logic/minecraft/Component.cpp +++ b/api/logic/minecraft/Component.cpp @@ -145,7 +145,7 @@ QDateTime Component::getReleaseDateTime() bool Component::isEnabled() { return !canBeDisabled() || !m_disabled; -}; +} bool Component::canBeDisabled() { @@ -171,7 +171,7 @@ bool Component::setEnabled(bool state) bool Component::isCustom() { return m_file != nullptr; -}; +} bool Component::isCustomizable() { diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index cd1afde4..237edaf1 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -59,7 +59,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class bool local = isLocal(); bool isForge = (hint() == "forge-pack-xz"); - auto add_download = [&](QString storage, QString url, QString sha1 = QString()) + auto add_download = [&](QString storage, QString url, QString sha1) { auto entry = cache->resolveEntry("libraries", storage); if(isAlwaysStale) @@ -208,14 +208,14 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class { QString cooked_storage = raw_storage; QString cooked_dl = raw_dl; - add_download(cooked_storage.replace("${arch}", "32"), cooked_dl.replace("${arch}", "32")); + add_download(cooked_storage.replace("${arch}", "32"), cooked_dl.replace("${arch}", "32"), QString()); cooked_storage = raw_storage; cooked_dl = raw_dl; - add_download(cooked_storage.replace("${arch}", "64"), cooked_dl.replace("${arch}", "64")); + add_download(cooked_storage.replace("${arch}", "64"), cooked_dl.replace("${arch}", "64"), QString()); } else { - add_download(raw_storage, raw_dl); + add_download(raw_storage, raw_dl, QString()); } } return out; diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h index 446a39d5..3be15b1c 100644 --- a/api/logic/minecraft/MinecraftInstance.h +++ b/api/logic/minecraft/MinecraftInstance.h @@ -18,7 +18,7 @@ public: MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); virtual ~MinecraftInstance() {}; virtual void init() override; - virtual void saveNow(); + virtual void saveNow() override; // FIXME: remove QString typeName() const override; diff --git a/api/logic/minecraft/World.cpp b/api/logic/minecraft/World.cpp index 227a9b75..d7bc4553 100644 --- a/api/logic/minecraft/World.cpp +++ b/api/logic/minecraft/World.cpp @@ -275,7 +275,7 @@ static QString read_string (nbt::value& parent, const char * name, const QString qWarning() << "NBT tag" << name << "could not be converted to string. Defaulting to" << fallback; return fallback; } -}; +} static int64_t read_long (nbt::value& parent, const char * name, const int64_t & fallback = 0) { @@ -301,7 +301,7 @@ static int64_t read_long (nbt::value& parent, const char * name, const int64_t & qWarning() << "NBT tag" << name << "could not be converted to long. Defaulting to" << fallback; return fallback; } -}; +} void World::loadFromLevelDat(QByteArray data) { diff --git a/api/logic/minecraft/launch/ModMinecraftJar.h b/api/logic/minecraft/launch/ModMinecraftJar.h index b9a2d35b..dca484f8 100644 --- a/api/logic/minecraft/launch/ModMinecraftJar.h +++ b/api/logic/minecraft/launch/ModMinecraftJar.h @@ -25,8 +25,8 @@ public: explicit ModMinecraftJar(LaunchTask *parent) : LaunchStep(parent) {}; virtual ~ModMinecraftJar(){}; - virtual void executeTask(); - virtual bool canAbort() const + virtual void executeTask() override; + virtual bool canAbort() const override { return false; } diff --git a/api/logic/modplatform/ftb/FtbPackInstallTask.cpp b/api/logic/modplatform/ftb/FtbPackInstallTask.cpp index b57c2092..7815ef46 100644 --- a/api/logic/modplatform/ftb/FtbPackInstallTask.cpp +++ b/api/logic/modplatform/ftb/FtbPackInstallTask.cpp @@ -57,7 +57,7 @@ void FtbPackInstallTask::onDownloadProgress(qint64 current, qint64 total) { abortable = true; progress(current, total * 4); - setStatus(tr("Downloading zip for %1 (%2\%)").arg(m_pack.name).arg(current / 10)); + setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10)); } void FtbPackInstallTask::unzip() diff --git a/api/logic/net/FileSink.cpp b/api/logic/net/FileSink.cpp index f52c5788..e3ff0498 100644 --- a/api/logic/net/FileSink.cpp +++ b/api/logic/net/FileSink.cpp @@ -10,12 +10,12 @@ FileSink::FileSink(QString filename) :m_filename(filename) { // nil -}; +} FileSink::~FileSink() { // nil -}; +} JobStatus FileSink::init(QNetworkRequest& request) { diff --git a/api/logic/net/MetaCacheSink.cpp b/api/logic/net/MetaCacheSink.cpp index c9d75310..b4b337d6 100644 --- a/api/logic/net/MetaCacheSink.cpp +++ b/api/logic/net/MetaCacheSink.cpp @@ -10,12 +10,12 @@ MetaCacheSink::MetaCacheSink(MetaEntryPtr entry, ChecksumValidator * md5sum) :Net::FileSink(entry->getFullPath()), m_entry(entry), m_md5Node(md5sum) { addValidator(md5sum); -}; +} MetaCacheSink::~MetaCacheSink() { // nil -}; +} JobStatus MetaCacheSink::initCache(QNetworkRequest& request) { diff --git a/api/logic/updater/GoUpdate.h b/api/logic/updater/GoUpdate.h index 95f26b8c..0e183b9f 100644 --- a/api/logic/updater/GoUpdate.h +++ b/api/logic/updater/GoUpdate.h @@ -133,4 +133,4 @@ bool MULTIMC_LOGIC_EXPORT processFileLists bool MULTIMC_LOGIC_EXPORT fixPathForOSX(QString &path); } -Q_DECLARE_METATYPE(GoUpdate::Status); \ No newline at end of file +Q_DECLARE_METATYPE(GoUpdate::Status) diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp index d59fceee..990b949e 100644 --- a/application/VersionProxyModel.cpp +++ b/application/VersionProxyModel.cpp @@ -227,7 +227,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const return QVariant(); } } -}; +} QModelIndex VersionProxyModel::parent(const QModelIndex &child) const { diff --git a/application/pages/BasePageProvider.h b/application/pages/BasePageProvider.h index 1cc7458a..05c38d23 100644 --- a/application/pages/BasePageProvider.h +++ b/application/pages/BasePageProvider.h @@ -34,6 +34,7 @@ public: : m_dialogTitle(dialogTitle) { } + virtual ~GenericPageProvider() {} QList getPages() override { diff --git a/application/setupwizard/AnalyticsWizardPage.h b/application/setupwizard/AnalyticsWizardPage.h index 03de9cb0..0234f02a 100644 --- a/application/setupwizard/AnalyticsWizardPage.h +++ b/application/setupwizard/AnalyticsWizardPage.h @@ -8,7 +8,7 @@ class QCheckBox; class AnalyticsWizardPage : public BaseWizardPage { - Q_OBJECT; + Q_OBJECT public: explicit AnalyticsWizardPage(QWidget *parent = Q_NULLPTR); virtual ~AnalyticsWizardPage(); diff --git a/application/setupwizard/JavaWizardPage.h b/application/setupwizard/JavaWizardPage.h index 4ea31d24..592fa24c 100644 --- a/application/setupwizard/JavaWizardPage.h +++ b/application/setupwizard/JavaWizardPage.h @@ -6,7 +6,7 @@ class JavaSettingsWidget; class JavaWizardPage : public BaseWizardPage { - Q_OBJECT; + Q_OBJECT public: explicit JavaWizardPage(QWidget *parent = Q_NULLPTR); diff --git a/application/setupwizard/LanguageWizardPage.h b/application/setupwizard/LanguageWizardPage.h index 8b55d57f..5a9e882d 100644 --- a/application/setupwizard/LanguageWizardPage.h +++ b/application/setupwizard/LanguageWizardPage.h @@ -7,7 +7,7 @@ class QListView; class LanguageWizardPage : public BaseWizardPage { - Q_OBJECT; + Q_OBJECT public: explicit LanguageWizardPage(QWidget *parent = Q_NULLPTR); diff --git a/libraries/classparser/src/constants.h b/libraries/classparser/src/constants.h index 9c74ab20..c3ef88fd 100644 --- a/libraries/classparser/src/constants.h +++ b/libraries/classparser/src/constants.h @@ -123,7 +123,26 @@ public: return ss.str(); } + struct ref_type_t + { + /** + * Class reference: + * an index within the constant pool to a UTF-8 string containing + * the fully qualified class name (in internal format) + * Used for j_class, j_fieldref, j_methodref and j_interface_methodref + */ + uint16_t class_idx; + // used for j_fieldref, j_methodref and j_interface_methodref + uint16_t name_and_type_idx; + }; + struct name_and_type_t + { + uint16_t name_index; + uint16_t descriptor_index; + }; + std::string str_data; /** String data in 'modified utf-8'.*/ + // store everything here. union { @@ -132,23 +151,8 @@ public: float float_data; double double_data; uint16_t index; - struct - { - /** - * Class reference: - * an index within the constant pool to a UTF-8 string containing - * the fully qualified class name (in internal format) - * Used for j_class, j_fieldref, j_methodref and j_interface_methodref - */ - uint16_t class_idx; - // used for j_fieldref, j_methodref and j_interface_methodref - uint16_t name_and_type_idx; - } ref_type; - struct - { - uint16_t name_index; - uint16_t descriptor_index; - } name_and_type; + ref_type_t ref_type; + name_and_type_t name_and_type; }; }; diff --git a/libraries/classparser/src/javaendian.h b/libraries/classparser/src/javaendian.h index d488b382..5e6fff55 100644 --- a/libraries/classparser/src/javaendian.h +++ b/libraries/classparser/src/javaendian.h @@ -44,33 +44,33 @@ inline uint64_t bigswap(uint64_t x) ((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) | ((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56); } -; + inline uint32_t bigswap(uint32_t x) { return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); } -; + inline uint16_t bigswap(uint16_t x) { return (x >> 8) | (x << 8); } -; + inline int64_t bigswap(int64_t x) { return (x >> 56) | ((x << 40) & 0x00FF000000000000) | ((x << 24) & 0x0000FF0000000000) | ((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) | ((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56); } -; + inline int32_t bigswap(int32_t x) { return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); } -; + inline int16_t bigswap(int16_t x) { return (x >> 8) | (x << 8); } -; + #endif } diff --git a/libraries/iconfix/xdgicon.cpp b/libraries/iconfix/xdgicon.cpp index a36d80a9..84665a7d 100644 --- a/libraries/iconfix/xdgicon.cpp +++ b/libraries/iconfix/xdgicon.cpp @@ -52,7 +52,7 @@ struct QtIconCache : public IconCache } }; } -Q_GLOBAL_STATIC(IconCache, qtIconCache); +Q_GLOBAL_STATIC(IconCache, qtIconCache) static void qt_cleanup_icon_cache() {