From da213d15341ce28841388542e63a6b69c5e5b8a2 Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Tue, 2 Jul 2019 12:37:44 -0600 Subject: [PATCH] More Zero/Null as pointer constant corrections (#1947) Further to pull request #1938. Changes were missed in previous commit. Resolve warnings `warning: zero as null pointer constant` in code by using C++ 11 recommended `nullptr`. --- gui/librarydialog.cpp | 8 +++----- test/testlibrary.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/gui/librarydialog.cpp b/gui/librarydialog.cpp index fae43083e..4a730c311 100644 --- a/gui/librarydialog.cpp +++ b/gui/librarydialog.cpp @@ -313,15 +313,13 @@ void LibraryDialog::editArg() return; CppcheckLibraryData::Function::Arg &arg = function->args[mUi->arguments->row(mUi->arguments->selectedItems().first())]; - LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg); - if (d->exec() == QDialog::Accepted) { + LibraryEditArgDialog d(nullptr, arg); + if (d.exec() == QDialog::Accepted) { unsigned number = arg.nr; - arg = d->getArg(); + arg = d.getArg(); arg.nr = number; mUi->arguments->selectedItems().first()->setText(getArgText(arg)); } - - delete d; mUi->buttonSave->setEnabled(true); } diff --git a/test/testlibrary.cpp b/test/testlibrary.cpp index 0e8c5e468..7ff70b48d 100644 --- a/test/testlibrary.cpp +++ b/test/testlibrary.cpp @@ -704,7 +704,7 @@ private: // s8 { const struct Library::PodType * const type = library.podtype("s8"); - ASSERT_EQUALS(true, type != 0); + ASSERT_EQUALS(true, type != nullptr); if (type) { ASSERT_EQUALS(1U, type->size); ASSERT_EQUALS('s', type->sign); @@ -713,7 +713,7 @@ private: // u8 { const struct Library::PodType * const type = library.podtype("u8"); - ASSERT_EQUALS(true, type != 0); + ASSERT_EQUALS(true, type != nullptr); if (type) { ASSERT_EQUALS(1U, type->size); ASSERT_EQUALS('u', type->sign); @@ -722,7 +722,7 @@ private: // u16 { const struct Library::PodType * const type = library.podtype("u16"); - ASSERT_EQUALS(true, type != 0); + ASSERT_EQUALS(true, type != nullptr); if (type) { ASSERT_EQUALS(2U, type->size); ASSERT_EQUALS('u', type->sign); @@ -731,7 +731,7 @@ private: // s16 { const struct Library::PodType * const type = library.podtype("s16"); - ASSERT_EQUALS(true, type != 0); + ASSERT_EQUALS(true, type != nullptr); if (type) { ASSERT_EQUALS(2U, type->size); ASSERT_EQUALS('s', type->sign); @@ -740,7 +740,7 @@ private: // robustness test: provide cfg without PodType { const struct Library::PodType * const type = library.podtype("nonExistingPodType"); - ASSERT_EQUALS(true, type == 0); + ASSERT_EQUALS(true, type == nullptr); } } }