From cebc28ce2f2daba73853828f4f81fb06b972e098 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 4 Mar 2019 13:34:34 +0100 Subject: Fix various clang-cl warnings ...in Windows-only code that has recently been brought back to life with db8a2a567087cb65ca420bfd582ea2c8c24fcd7b "tdf#39625 make sal/qa/systools/test_comtools.cxx work with CppUnit" Change-Id: Ia93e84f5719c2320789aec5f711067f9174acb55 Reviewed-on: https://gerrit.libreoffice.org/68682 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sal/qa/systools/test_comtools.cxx | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'sal/qa') diff --git a/sal/qa/systools/test_comtools.cxx b/sal/qa/systools/test_comtools.cxx index 42e5215d729d..284a28b1f407 100644 --- a/sal/qa/systools/test_comtools.cxx +++ b/sal/qa/systools/test_comtools.cxx @@ -28,17 +28,17 @@ public: { } - ~COMObject() + virtual ~COMObject() { } - ULONG __stdcall AddRef() + ULONG __stdcall AddRef() override { ref_count_++; return ref_count_; } - ULONG __stdcall Release() + ULONG __stdcall Release() override { ULONG cnt = --ref_count_; if (cnt == 0) @@ -46,7 +46,7 @@ public: return cnt; } - HRESULT __stdcall QueryInterface(REFIID riid, LPVOID* ppv) + HRESULT __stdcall QueryInterface(REFIID riid, LPVOID* ppv) override { if (riid == IID_IUnknown) { @@ -66,12 +66,12 @@ private: ULONG ref_count_; }; -sal::systools::COMReference comObjectSource() +static sal::systools::COMReference comObjectSource() { return sal::systools::COMReference(new COMObject); } -bool comObjectSink(sal::systools::COMReference r, ULONG expectedRefCountOnReturn) +static bool comObjectSink(sal::systools::COMReference r, ULONG expectedRefCountOnReturn) { r = sal::systools::COMReference(); COMObject* p = reinterpret_cast(r.get()); @@ -81,7 +81,7 @@ bool comObjectSink(sal::systools::COMReference r, ULONG expectedRefCou return (0 == expectedRefCountOnReturn); } -void comObjectSource2(LPVOID* ppv) +static void comObjectSource2(LPVOID* ppv) { COMObject* p = new COMObject; p->AddRef(); @@ -99,7 +99,7 @@ namespace test_comtools void default_ctor() { sal::systools::COMReference r; - CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("COMReference should be empty", static_cast(nullptr), r.get()); } void test_ctor_manual_AddRef() @@ -107,44 +107,44 @@ namespace test_comtools COMObject* p = new COMObject; p->AddRef(); sal::systools::COMReference r(p, false); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); } void test_copy_ctor() { sal::systools::COMReference r(comObjectSource()); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); } void test_copy_assignment() { sal::systools::COMReference r; - CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("COMReference should be empty", static_cast(nullptr), r.get()); r = comObjectSource(); - CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() != NULL); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() != nullptr); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); } void test_ref_to_ref_assignment() { sal::systools::COMReference r1 = comObjectSource(); sal::systools::COMReference r2 = r1; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast(r2.get())->GetRefCount() == 2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 2 is expected", ULONG(2), reinterpret_cast(r2.get())->GetRefCount()); } void test_pointer_to_ref_assignment() { sal::systools::COMReference r; r = new COMObject; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); } void test_pointer_to_ref_assignment2() { sal::systools::COMReference r = comObjectSource(); r = new COMObject; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); } void test_source_sink() @@ -156,23 +156,23 @@ namespace test_comtools { sal::systools::COMReference r; comObjectSource2(reinterpret_cast(&r)); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count, 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); } void test_address_operator2() { sal::systools::COMReference r1 = comObjectSource(); sal::systools::COMReference r2 = r1; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast(r2.get())->GetRefCount() == 2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 2 is expected", ULONG(2), reinterpret_cast(r2.get())->GetRefCount()); comObjectSource2(reinterpret_cast(&r1)); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r1.get())->GetRefCount() == 1); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r2.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r1.get())->GetRefCount()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r2.get())->GetRefCount()); } void test_clear() { sal::systools::COMReference r = comObjectSource(); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast(r.get())->GetRefCount()); r.clear(); CPPUNIT_ASSERT_MESSAGE("Expect reference to be empty", !r.is()); } @@ -183,7 +183,7 @@ namespace test_comtools { sal::systools::COMReference r1 = comObjectSource(); sal::systools::COMReference r2 = r1.QueryInterface(IID_IUnknown); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 2 is expected", reinterpret_cast(r2.get())->GetRefCount() == 2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count, 2 is expected", ULONG(2), reinterpret_cast(r2.get())->GetRefCount()); } catch(const sal::systools::ComError&) { -- cgit v1.2.3