NOISSUE fix all sorts of warnings, enable Werror and pedantic

This commit is contained in:
Petr Mrázek 2018-06-28 23:18:45 +02:00
parent b5f636b3d5
commit 7fe94ca7b4
21 changed files with 55 additions and 49 deletions

View File

@ -32,7 +32,7 @@ set(CMAKE_C_STANDARD_REQUIRED true)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
include(GenerateExportHeader) 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) if(UNIX AND APPLE)
set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
endif() endif()

View File

@ -34,4 +34,4 @@ namespace DesktopServices
* Open the URL, most likely in a browser. Maybe. * Open the URL, most likely in a browser. Maybe.
*/ */
MULTIMC_GUI_EXPORT bool openUrl(const QUrl &url); MULTIMC_GUI_EXPORT bool openUrl(const QUrl &url);
}; }

View File

@ -7,8 +7,9 @@
class QUrl; class QUrl;
struct MULTIMC_LOGIC_EXPORT Version class MULTIMC_LOGIC_EXPORT Version
{ {
public:
Version(const QString &str); Version(const QString &str);
Version() {} Version() {}

View File

@ -80,4 +80,4 @@ void serializeRequires(QJsonObject & objOut, RequireSet* ptr, const char * keyNa
MetadataVersion currentFormatVersion(); MetadataVersion currentFormatVersion();
} }
Q_DECLARE_METATYPE(std::set<Meta::Require>); Q_DECLARE_METATYPE(std::set<Meta::Require>)

View File

@ -145,7 +145,7 @@ QDateTime Component::getReleaseDateTime()
bool Component::isEnabled() bool Component::isEnabled()
{ {
return !canBeDisabled() || !m_disabled; return !canBeDisabled() || !m_disabled;
}; }
bool Component::canBeDisabled() bool Component::canBeDisabled()
{ {
@ -171,7 +171,7 @@ bool Component::setEnabled(bool state)
bool Component::isCustom() bool Component::isCustom()
{ {
return m_file != nullptr; return m_file != nullptr;
}; }
bool Component::isCustomizable() bool Component::isCustomizable()
{ {

View File

@ -59,7 +59,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class
bool local = isLocal(); bool local = isLocal();
bool isForge = (hint() == "forge-pack-xz"); 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); auto entry = cache->resolveEntry("libraries", storage);
if(isAlwaysStale) if(isAlwaysStale)
@ -208,14 +208,14 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class
{ {
QString cooked_storage = raw_storage; QString cooked_storage = raw_storage;
QString cooked_dl = raw_dl; 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_storage = raw_storage;
cooked_dl = raw_dl; 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 else
{ {
add_download(raw_storage, raw_dl); add_download(raw_storage, raw_dl, QString());
} }
} }
return out; return out;

View File

@ -18,7 +18,7 @@ public:
MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir);
virtual ~MinecraftInstance() {}; virtual ~MinecraftInstance() {};
virtual void init() override; virtual void init() override;
virtual void saveNow(); virtual void saveNow() override;
// FIXME: remove // FIXME: remove
QString typeName() const override; QString typeName() const override;

View File

@ -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; qWarning() << "NBT tag" << name << "could not be converted to string. Defaulting to" << fallback;
return fallback; return fallback;
} }
}; }
static int64_t read_long (nbt::value& parent, const char * name, const int64_t & fallback = 0) 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; qWarning() << "NBT tag" << name << "could not be converted to long. Defaulting to" << fallback;
return fallback; return fallback;
} }
}; }
void World::loadFromLevelDat(QByteArray data) void World::loadFromLevelDat(QByteArray data)
{ {

View File

@ -25,8 +25,8 @@ public:
explicit ModMinecraftJar(LaunchTask *parent) : LaunchStep(parent) {}; explicit ModMinecraftJar(LaunchTask *parent) : LaunchStep(parent) {};
virtual ~ModMinecraftJar(){}; virtual ~ModMinecraftJar(){};
virtual void executeTask(); virtual void executeTask() override;
virtual bool canAbort() const virtual bool canAbort() const override
{ {
return false; return false;
} }

View File

@ -57,7 +57,7 @@ void FtbPackInstallTask::onDownloadProgress(qint64 current, qint64 total)
{ {
abortable = true; abortable = true;
progress(current, total * 4); 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() void FtbPackInstallTask::unzip()

View File

@ -10,12 +10,12 @@ FileSink::FileSink(QString filename)
:m_filename(filename) :m_filename(filename)
{ {
// nil // nil
}; }
FileSink::~FileSink() FileSink::~FileSink()
{ {
// nil // nil
}; }
JobStatus FileSink::init(QNetworkRequest& request) JobStatus FileSink::init(QNetworkRequest& request)
{ {

View File

@ -10,12 +10,12 @@ MetaCacheSink::MetaCacheSink(MetaEntryPtr entry, ChecksumValidator * md5sum)
:Net::FileSink(entry->getFullPath()), m_entry(entry), m_md5Node(md5sum) :Net::FileSink(entry->getFullPath()), m_entry(entry), m_md5Node(md5sum)
{ {
addValidator(md5sum); addValidator(md5sum);
}; }
MetaCacheSink::~MetaCacheSink() MetaCacheSink::~MetaCacheSink()
{ {
// nil // nil
}; }
JobStatus MetaCacheSink::initCache(QNetworkRequest& request) JobStatus MetaCacheSink::initCache(QNetworkRequest& request)
{ {

View File

@ -133,4 +133,4 @@ bool MULTIMC_LOGIC_EXPORT processFileLists
bool MULTIMC_LOGIC_EXPORT fixPathForOSX(QString &path); bool MULTIMC_LOGIC_EXPORT fixPathForOSX(QString &path);
} }
Q_DECLARE_METATYPE(GoUpdate::Status); Q_DECLARE_METATYPE(GoUpdate::Status)

View File

@ -227,7 +227,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
return QVariant(); return QVariant();
} }
} }
}; }
QModelIndex VersionProxyModel::parent(const QModelIndex &child) const QModelIndex VersionProxyModel::parent(const QModelIndex &child) const
{ {

View File

@ -34,6 +34,7 @@ public:
: m_dialogTitle(dialogTitle) : m_dialogTitle(dialogTitle)
{ {
} }
virtual ~GenericPageProvider() {}
QList<BasePage *> getPages() override QList<BasePage *> getPages() override
{ {

View File

@ -8,7 +8,7 @@ class QCheckBox;
class AnalyticsWizardPage : public BaseWizardPage class AnalyticsWizardPage : public BaseWizardPage
{ {
Q_OBJECT; Q_OBJECT
public: public:
explicit AnalyticsWizardPage(QWidget *parent = Q_NULLPTR); explicit AnalyticsWizardPage(QWidget *parent = Q_NULLPTR);
virtual ~AnalyticsWizardPage(); virtual ~AnalyticsWizardPage();

View File

@ -6,7 +6,7 @@ class JavaSettingsWidget;
class JavaWizardPage : public BaseWizardPage class JavaWizardPage : public BaseWizardPage
{ {
Q_OBJECT; Q_OBJECT
public: public:
explicit JavaWizardPage(QWidget *parent = Q_NULLPTR); explicit JavaWizardPage(QWidget *parent = Q_NULLPTR);

View File

@ -7,7 +7,7 @@ class QListView;
class LanguageWizardPage : public BaseWizardPage class LanguageWizardPage : public BaseWizardPage
{ {
Q_OBJECT; Q_OBJECT
public: public:
explicit LanguageWizardPage(QWidget *parent = Q_NULLPTR); explicit LanguageWizardPage(QWidget *parent = Q_NULLPTR);

View File

@ -123,7 +123,26 @@ public:
return ss.str(); 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'.*/ std::string str_data; /** String data in 'modified utf-8'.*/
// store everything here. // store everything here.
union union
{ {
@ -132,23 +151,8 @@ public:
float float_data; float float_data;
double double_data; double double_data;
uint16_t index; uint16_t index;
struct ref_type_t ref_type;
{ name_and_type_t name_and_type;
/**
* 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;
}; };
}; };

View File

@ -44,33 +44,33 @@ inline uint64_t bigswap(uint64_t x)
((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) | ((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) |
((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56); ((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56);
} }
;
inline uint32_t bigswap(uint32_t x) inline uint32_t bigswap(uint32_t x)
{ {
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
} }
;
inline uint16_t bigswap(uint16_t x) inline uint16_t bigswap(uint16_t x)
{ {
return (x >> 8) | (x << 8); return (x >> 8) | (x << 8);
} }
;
inline int64_t bigswap(int64_t x) inline int64_t bigswap(int64_t x)
{ {
return (x >> 56) | ((x << 40) & 0x00FF000000000000) | ((x << 24) & 0x0000FF0000000000) | return (x >> 56) | ((x << 40) & 0x00FF000000000000) | ((x << 24) & 0x0000FF0000000000) |
((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) | ((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) |
((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56); ((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56);
} }
;
inline int32_t bigswap(int32_t x) inline int32_t bigswap(int32_t x)
{ {
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
} }
;
inline int16_t bigswap(int16_t x) inline int16_t bigswap(int16_t x)
{ {
return (x >> 8) | (x << 8); return (x >> 8) | (x << 8);
} }
;
#endif #endif
} }

View File

@ -52,7 +52,7 @@ struct QtIconCache : public IconCache
} }
}; };
} }
Q_GLOBAL_STATIC(IconCache, qtIconCache); Q_GLOBAL_STATIC(IconCache, qtIconCache)
static void qt_cleanup_icon_cache() static void qt_cleanup_icon_cache()
{ {