From 70824729ff2fcc6cfa751907be44a4292a2395f7 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Tue, 17 Mar 2020 03:29:55 -0700 Subject: [PATCH] chore(cleanup): don't use 0 as nullptr Don't add Wzero-as-null-pointer-constant by default, since on older Qt versions that we stil support and that our CI runs agains, Qt API themselves cause warnings which lead to build errors all over the place. Fix #6008 --- src/nexus.cpp | 2 +- src/persistence/db/rawdatabase.cpp | 4 +++- src/persistence/db/rawdatabase.h | 3 +++ src/platform/autorun_win.cpp | 6 +++--- src/platform/camera/directshow.cpp | 6 +++--- test/model/groupmessagedispatcher_test.cpp | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/nexus.cpp b/src/nexus.cpp index 3b05f53fb..66c6014fa 100644 --- a/src/nexus.cpp +++ b/src/nexus.cpp @@ -113,7 +113,7 @@ void Nexus::start() #ifdef Q_OS_MAC // TODO: still needed? - globalMenuBar = new QMenuBar(0); + globalMenuBar = new QMenuBar(); dockMenu = new QMenu(globalMenuBar); viewMenu = globalMenuBar->addMenu(QString()); diff --git a/src/persistence/db/rawdatabase.cpp b/src/persistence/db/rawdatabase.cpp index 865e303fe..8526b5482 100644 --- a/src/persistence/db/rawdatabase.cpp +++ b/src/persistence/db/rawdatabase.cpp @@ -738,7 +738,9 @@ void RawDatabase::process() const QByteArray& blob = query.blobs[curParam + i]; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wold-style-cast" - // SQLITE_STATIC uses old-style cast and comes from system headers, so can't be fixed by us +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + // SQLITE_STATIC uses old-style cast and 0 as null pointer butcomes from system headers, so can't + // be fixed by us auto sqliteDataType = SQLITE_STATIC; #pragma GCC diagnostic pop if (sqlite3_bind_blob(stmt, i + 1, blob.data(), blob.size(), sqliteDataType) diff --git a/src/persistence/db/rawdatabase.h b/src/persistence/db/rawdatabase.h index bf34a15fb..ad2a8a0c6 100644 --- a/src/persistence/db/rawdatabase.h +++ b/src/persistence/db/rawdatabase.h @@ -39,7 +39,10 @@ #define SQLITE_HAS_CODEC #define SQLITE_TEMP_STORE 2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #include +#pragma GCC diagnostic pop using RowId = NamedType; Q_DECLARE_METATYPE(RowId); diff --git a/src/platform/autorun_win.cpp b/src/platform/autorun_win.cpp index b6ff1de94..6d7c38fdf 100644 --- a/src/platform/autorun_win.cpp +++ b/src/platform/autorun_win.cpp @@ -57,7 +57,7 @@ inline tstring currentRegistryKeyName() bool Platform::setAutorun(bool on) { - HKEY key = 0; + HKEY key = nullptr; if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS) @@ -80,7 +80,7 @@ bool Platform::setAutorun(bool on) bool Platform::getAutorun() { - HKEY key = 0; + HKEY key = nullptr; if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS) @@ -93,7 +93,7 @@ bool Platform::getAutorun() DWORD type = REG_SZ; bool result = false; - if (RegQueryValueEx(key, keyName.c_str(), 0, &type, const_cast(reinterpret_cast(path)), &length) == ERROR_SUCCESS + if (RegQueryValueEx(key, keyName.c_str(), nullptr, &type, const_cast(reinterpret_cast(path)), &length) == ERROR_SUCCESS && type == REG_SZ) result = true; diff --git a/src/platform/camera/directshow.cpp b/src/platform/camera/directshow.cpp index 13ce56d98..4a85a3e17 100644 --- a/src/platform/camera/directshow.cpp +++ b/src/platform/camera/directshow.cpp @@ -42,10 +42,10 @@ static char* wcharToUtf8(wchar_t* w) { - int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0); + int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, nullptr, 0, nullptr, nullptr); char* s = new char[l]; if (s) - WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, 0, 0); + WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, nullptr, nullptr); return s; } @@ -157,7 +157,7 @@ static IBaseFilter* getDevFilter(QString devName) if (devName != devIdString) goto fail; - if (m->BindToObject(0, 0, IID_IBaseFilter, reinterpret_cast(&devFilter)) != S_OK) + if (m->BindToObject(nullptr, nullptr, IID_IBaseFilter, reinterpret_cast(&devFilter)) != S_OK) goto fail; fail: diff --git a/test/model/groupmessagedispatcher_test.cpp b/test/model/groupmessagedispatcher_test.cpp index 30591b373..e8d0372d4 100644 --- a/test/model/groupmessagedispatcher_test.cpp +++ b/test/model/groupmessagedispatcher_test.cpp @@ -55,7 +55,7 @@ class MockGroupQuery : public ICoreGroupQuery public: GroupId getGroupPersistentId(uint32_t groupNumber) const override { - return GroupId(0); + return GroupId(); } uint32_t getGroupNumberPeers(int groupId) const override @@ -211,7 +211,7 @@ void TestGroupMessageDispatcher::init() groupQuery = std::unique_ptr(new MockGroupQuery()); coreIdHandler = std::unique_ptr(new MockCoreIdHandler()); g = std::unique_ptr( - new Group(0, GroupId(0), "TestGroup", false, "me", *groupQuery, *coreIdHandler)); + new Group(0, GroupId(), "TestGroup", false, "me", *groupQuery, *coreIdHandler)); messageSender = std::unique_ptr(new MockGroupMessageSender()); sharedProcessorParams = std::unique_ptr(new MessageProcessor::SharedParams());