diff --git a/Externals/cpp-optparse/OptionParser.h b/Externals/cpp-optparse/OptionParser.h index aab832c00c25..d9f9ff65ec24 100644 --- a/Externals/cpp-optparse/OptionParser.h +++ b/Externals/cpp-optparse/OptionParser.h @@ -77,7 +77,7 @@ class Values { class Option { public: Option(const OptionParser& p) : - _parser(p), _action("store"), _type("string"), _nargs(1), _callback(0) {} + _parser(p), _action("store"), _type("string"), _nargs(1), _callback(nullptr) {} virtual ~Option() {} Option& action(const std::string& a); diff --git a/Externals/picojson/picojson.h b/Externals/picojson/picojson.h index 8d09f05fe163..c136b11c2523 100644 --- a/Externals/picojson/picojson.h +++ b/Externals/picojson/picojson.h @@ -1063,7 +1063,7 @@ template inline std::string parse(value &out, Iter &pos, const I template inline Iter _parse(Context &ctx, const Iter &first, const Iter &last, std::string *err) { input in(first, last); - if (!_parse(ctx, in) && err != NULL) { + if (!_parse(ctx, in) && err != nullptr) { char buf[64]; SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line()); *err = buf; diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4a4cd61b5133..b23aeb9d3edc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -34,7 +34,7 @@ else() #check_and_add_flag(SWITCH_DEFAULT -Wswitch-default) #check_and_add_flag(FLOAT_EQUAL -Wfloat-equal) #check_and_add_flag(CONVERSION -Wconversion) - #check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant) + check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant) check_and_add_flag(TYPE_LIMITS -Wtype-limits) check_and_add_flag(SIGN_COMPARE -Wsign-compare) check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers) diff --git a/Source/Core/Common/FatFsUtil.cpp b/Source/Core/Common/FatFsUtil.cpp index f194dc22a3cc..395d6ac3eb6f 100644 --- a/Source/Core/Common/FatFsUtil.cpp +++ b/Source/Core/Common/FatFsUtil.cpp @@ -571,7 +571,15 @@ bool SyncSDFolderToSDImage(const std::function& cancelled, bool determin FatFsErrorToString(mount_error_code)); return false; } + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif Common::ScopeGuard unmount_guard{[] { f_unmount(""); }}; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif if (!Pack(cancelled, root, true, tmp_buffer)) { @@ -795,7 +803,15 @@ bool SyncSDImageToSDFolder(const std::function& cancelled) FatFsErrorToString(mount_error_code)); return false; } + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif Common::ScopeGuard unmount_guard{[] { f_unmount(""); }}; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // Unpack() and GetTempFilenameForAtomicWrite() don't want the trailing separator. const std::string target_dir_without_slash = target_dir.substr(0, target_dir.length() - 1); diff --git a/Source/Core/Common/GL/GLInterface/GLX.cpp b/Source/Core/Common/GL/GLInterface/GLX.cpp index b04296d0968f..ce16bb21553b 100644 --- a/Source/Core/Common/GL/GLInterface/GLX.cpp +++ b/Source/Core/Common/GL/GLInterface/GLX.cpp @@ -155,7 +155,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, None}}; s_glxError = false; - m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs[0]); + m_context = + glXCreateContextAttribs(m_display, m_fbconfig, nullptr, True, &context_attribs[0]); XSync(m_display, False); if (!m_context || s_glxError) continue; @@ -174,7 +175,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor std::array context_attribs_legacy = { {GLX_CONTEXT_MAJOR_VERSION_ARB, 1, GLX_CONTEXT_MINOR_VERSION_ARB, 0, None}}; s_glxError = false; - m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs_legacy[0]); + m_context = + glXCreateContextAttribs(m_display, m_fbconfig, nullptr, True, &context_attribs_legacy[0]); XSync(m_display, False); m_attribs.clear(); m_attribs.insert(m_attribs.end(), context_attribs_legacy.begin(), context_attribs_legacy.end()); diff --git a/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp b/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp index 16ba1b1ad78a..f8e87c0bfac9 100644 --- a/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp +++ b/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp @@ -294,7 +294,14 @@ ErrorCode OpenVFF(const std::string& path, const std::string& filename, return; } +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif Common::ScopeGuard unmount_guard{[] { f_unmount(""); }}; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif const auto write_error_code = WriteFile(filename, data); if (write_error_code != WC24_OK) diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index 72f591c7f576..2edb6bf0c41d 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -16,7 +16,14 @@ #include #include +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #include "Common/ChunkFile.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/IOS/USB/Host.cpp b/Source/Core/Core/IOS/USB/Host.cpp index 8870f730b058..5f4d3208efc3 100644 --- a/Source/Core/Core/IOS/USB/Host.cpp +++ b/Source/Core/Core/IOS/USB/Host.cpp @@ -11,7 +11,14 @@ #include #ifdef __LIBUSB__ +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #endif #include "Common/Assert.h" diff --git a/Source/Core/Core/IOS/USB/LibusbDevice.cpp b/Source/Core/Core/IOS/USB/LibusbDevice.cpp index 9e305b917981..0b01c0ddd372 100644 --- a/Source/Core/Core/IOS/USB/LibusbDevice.cpp +++ b/Source/Core/Core/IOS/USB/LibusbDevice.cpp @@ -13,7 +13,14 @@ #include #include +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #include "Common/Assert.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp index 62e8ec2987ca..4d147b1d3baf 100644 --- a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp +++ b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp @@ -103,7 +103,7 @@ std::optional USB_HIDv4::GetDeviceChange(const IOCtlRequest& request) IPCReply USB_HIDv4::Shutdown(const IOCtlRequest& request) { std::lock_guard lk{m_devicechange_hook_address_mutex}; - if (m_devicechange_hook_request != 0) + if (m_devicechange_hook_request) { auto& system = Core::System::GetInstance(); auto& memory = system.GetMemory(); diff --git a/Source/Core/Core/LibusbUtils.cpp b/Source/Core/Core/LibusbUtils.cpp index 1b1852dddd11..7eb628b09b88 100644 --- a/Source/Core/Core/LibusbUtils.cpp +++ b/Source/Core/Core/LibusbUtils.cpp @@ -7,7 +7,14 @@ #include #if defined(__LIBUSB__) +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #endif #include "Common/Assert.h" diff --git a/Source/Core/Core/PowerPC/Expression.cpp b/Source/Core/Core/PowerPC/Expression.cpp index 597c77c98550..ffa9bc96ae75 100644 --- a/Source/Core/Core/PowerPC/Expression.cpp +++ b/Source/Core/Core/PowerPC/Expression.cpp @@ -11,7 +11,14 @@ #include #include +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #include "Common/BitUtils.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index 94d3e2e0608b..4356fdad98e2 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -1048,7 +1048,7 @@ void InitLocal(const char* socket) addr.sun_family = AF_UNIX; strcpy(addr.sun_path, socket); - InitGeneric(PF_LOCAL, (const sockaddr*)&addr, sizeof(addr), NULL, NULL); + InitGeneric(PF_LOCAL, (const sockaddr*)&addr, sizeof(addr), nullptr, nullptr); } #endif diff --git a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp index 5ef3e0aa08fe..b2c4eb75d59d 100644 --- a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp +++ b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp @@ -75,7 +75,7 @@ QLayoutItem* FlowLayout::takeAt(int index) if (index >= 0 && index < m_item_list.size()) return m_item_list.takeAt(index); else - return 0; + return nullptr; } Qt::Orientations FlowLayout::expandingDirections() const @@ -167,7 +167,7 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const else if (parent->isWidgetType()) { QWidget* pw = static_cast(parent); - return pw->style()->pixelMetric(pm, 0, pw); + return pw->style()->pixelMetric(pm, nullptr, pw); } else { diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp index 55510fd9f94f..a19fce31fbae 100644 --- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp @@ -410,7 +410,7 @@ void GameCubePane::BrowseMemcard(ExpansionInterface::Slot slot) const QString filename = DolphinFileDialog::getSaveFileName( this, tr("Choose a file to open or create"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)), - tr("GameCube Memory Cards (*.raw *.gcp)"), 0, QFileDialog::DontConfirmOverwrite); + tr("GameCube Memory Cards (*.raw *.gcp)"), nullptr, QFileDialog::DontConfirmOverwrite); if (!filename.isEmpty()) SetMemcard(slot, filename); @@ -618,7 +618,7 @@ void GameCubePane::BrowseAGPRom(ExpansionInterface::Slot slot) QString filename = DolphinFileDialog::getSaveFileName( this, tr("Choose a file to open"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)), - tr("Game Boy Advance Carts (*.gba)"), 0, QFileDialog::DontConfirmOverwrite); + tr("Game Boy Advance Carts (*.gba)"), nullptr, QFileDialog::DontConfirmOverwrite); if (!filename.isEmpty()) SetAGPRom(slot, filename); diff --git a/Source/Core/DolphinQt/ToolBar.cpp b/Source/Core/DolphinQt/ToolBar.cpp index 49f384848d72..b50e48bf9eac 100644 --- a/Source/Core/DolphinQt/ToolBar.cpp +++ b/Source/Core/DolphinQt/ToolBar.cpp @@ -154,14 +154,14 @@ void ToolBar::UpdatePausePlayButtonState(const bool playing_state) { if (playing_state) { - disconnect(m_pause_play_action, 0, 0, 0); + disconnect(m_pause_play_action, nullptr, nullptr, nullptr); m_pause_play_action->setText(tr("Pause")); m_pause_play_action->setIcon(Resources::GetScaledThemeIcon("pause")); connect(m_pause_play_action, &QAction::triggered, this, &ToolBar::PausePressed); } else { - disconnect(m_pause_play_action, 0, 0, 0); + disconnect(m_pause_play_action, nullptr, nullptr, nullptr); m_pause_play_action->setText(tr("Play")); m_pause_play_action->setIcon(Resources::GetScaledThemeIcon("play")); connect(m_pause_play_action, &QAction::triggered, this, &ToolBar::PlayPressed); diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index a3853e9e6cf3..7780d486dd3c 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -17,7 +17,14 @@ #include #if GCADAPTER_USE_LIBUSB_IMPLEMENTATION +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #elif GCADAPTER_USE_ANDROID_IMPLEMENTATION #include #endif diff --git a/Source/Core/UICommon/Disassembler.cpp b/Source/Core/UICommon/Disassembler.cpp index 62e4d32c6d26..15555dc0b9ef 100644 --- a/Source/Core/UICommon/Disassembler.cpp +++ b/Source/Core/UICommon/Disassembler.cpp @@ -46,7 +46,7 @@ HostDisassemblerLLVM::HostDisassemblerLLVM(const std::string& host_disasm, int i LLVMInitializeAllTargetMCs(); LLVMInitializeAllDisassemblers(); - m_llvm_context = LLVMCreateDisasmCPU(host_disasm.c_str(), cpu.c_str(), nullptr, 0, 0, nullptr); + m_llvm_context = LLVMCreateDisasmCPU(host_disasm.c_str(), cpu.c_str(), nullptr, 0, nullptr, nullptr); // Couldn't create llvm context if (!m_llvm_context) diff --git a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp index 355dc8acf2b5..7f670e774828 100644 --- a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp +++ b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp @@ -36,7 +36,7 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path) return; } - if (unzLocateFile(file, "manifest.json", 0) == UNZ_END_OF_LIST_OF_FILE) + if (unzLocateFile(file, "manifest.json", nullptr) == UNZ_END_OF_LIST_OF_FILE) { m_valid = false; m_error = "Resource pack is missing a manifest."; @@ -63,7 +63,7 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path) return; } - if (unzLocateFile(file, "logo.png", 0) != UNZ_END_OF_LIST_OF_FILE) + if (unzLocateFile(file, "logo.png", nullptr) != UNZ_END_OF_LIST_OF_FILE) { unz_file_info64 logo_info{}; unzGetCurrentFileInfo64(file, &logo_info, nullptr, 0, nullptr, 0, nullptr, 0); diff --git a/Source/Core/UICommon/USBUtils.cpp b/Source/Core/UICommon/USBUtils.cpp index 2264afe82cca..f86dbb7169ba 100644 --- a/Source/Core/UICommon/USBUtils.cpp +++ b/Source/Core/UICommon/USBUtils.cpp @@ -7,7 +7,14 @@ #include #ifdef __LIBUSB__ +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #endif #include "Common/CommonTypes.h" diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp index ad0e32bb390e..4e90211c59f3 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp +++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp @@ -296,7 +296,7 @@ OGLStagingTexture::OGLStagingTexture(StagingTextureType type, const TextureConfi OGLStagingTexture::~OGLStagingTexture() { - if (m_fence != 0) + if (m_fence != nullptr) glDeleteSync(m_fence); if (m_map_pointer) { @@ -418,7 +418,7 @@ void OGLStagingTexture::CopyFromTexture(const AbstractTexture* src, // If we support buffer storage, create a fence for synchronization. if (UsePersistentStagingBuffers()) { - if (m_fence != 0) + if (m_fence != nullptr) glDeleteSync(m_fence); glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); @@ -479,7 +479,7 @@ void OGLStagingTexture::CopyToTexture(const MathUtil::Rectangle& src_rect, // If we support buffer storage, create a fence for synchronization. if (UsePersistentStagingBuffers()) { - if (m_fence != 0) + if (m_fence != nullptr) glDeleteSync(m_fence); m_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); @@ -493,7 +493,7 @@ void OGLStagingTexture::Flush() { // No-op when not using buffer storage, as the transfers happen on Map(). // m_fence will always be zero in this case. - if (m_fence == 0) + if (m_fence == nullptr) { m_needs_flush = false; return; @@ -501,7 +501,7 @@ void OGLStagingTexture::Flush() glClientWaitSync(m_fence, 0, GL_TIMEOUT_IGNORED); glDeleteSync(m_fence); - m_fence = 0; + m_fence = nullptr; m_needs_flush = false; } diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.h b/Source/Core/VideoBackends/OGL/OGLTexture.h index 9d1c11950597..f80aa98725a8 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.h +++ b/Source/Core/VideoBackends/OGL/OGLTexture.h @@ -75,7 +75,7 @@ class OGLStagingTexture final : public AbstractStagingTexture GLenum m_target; GLuint m_buffer_name; size_t m_buffer_size; - GLsync m_fence = 0; + GLsync m_fence = nullptr; }; class OGLFramebuffer final : public AbstractFramebuffer