diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-07-05 10:40:05 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-07-05 17:39:50 +0200 |
commit | 6209fcbdc694ca0ef22f157d3f5c5b74ed8c76c8 (patch) | |
tree | 05743a37ba61af4281286c1c56cf8766c8caa860 | |
parent | c3a4dacfa0aae3cf40aa7b123672c6bc197efe0f (diff) |
coverity#1414486 Unchecked dynamic_cast
and
coverity#1414482 Unchecked dynamic_cast
coverity#1414480 Unchecked dynamic_cast
coverity#1414479 Unchecked dynamic_cast
Change-Id: Ia33e4cfa5c13beeae5dfa46411f526433d87ea99
Reviewed-on: https://gerrit.libreoffice.org/39568
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 9 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 15 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 5 |
3 files changed, 18 insertions, 11 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index c90032a8c0ca..521735ebd4fc 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1389,7 +1389,9 @@ void ScTiledRenderingTest::testDisableUndoRepair() CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet1.GetItem(SID_UNDO))); CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet2.GetItemState(SID_UNDO)); CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aSet2.GetItem(SID_UNDO))); - CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item* >(aSet2.GetItem(SID_UNDO))->GetValue()); + const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item*>(aSet2.GetItem(SID_UNDO)); + CPPUNIT_ASSERT(pUInt32Item); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), pUInt32Item->GetValue()); } // text edit a cell in view #2 @@ -1407,8 +1409,9 @@ void ScTiledRenderingTest::testDisableUndoRepair() pView1->GetSlotState(SID_UNDO, nullptr, &aSet1); pView2->GetSlotState(SID_UNDO, nullptr, &aSet2); CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet1.GetItemState(SID_UNDO)); - CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aSet1.GetItem(SID_UNDO))); - CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item* >(aSet1.GetItem(SID_UNDO))->GetValue()); + const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item*>(aSet1.GetItem(SID_UNDO)); + CPPUNIT_ASSERT(pUInt32Item); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), pUInt32Item->GetValue()); CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet2.GetItemState(SID_UNDO)); CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet2.GetItem(SID_UNDO))); } diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 0ff3e16717c1..715b444e5262 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1196,8 +1196,9 @@ void SdTiledRenderingTest::testUndoLimiting() SfxRequest aReq2(SID_UNDO, SfxCallMode::SLOT, pXImpressDocument->GetDocShell()->GetDoc()->GetPool()); aReq2.AppendItem(SfxUInt16Item(SID_UNDO, 1)); pViewShell2->ExecuteSlot(aReq2); - CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aReq2.GetReturnValue())); - CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item * >(aReq2.GetReturnValue())->GetValue()); + const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item*>(aReq2.GetReturnValue()); + CPPUNIT_ASSERT(pUInt32Item); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), pUInt32Item->GetValue()); } // Now check view1 can undo action @@ -1800,8 +1801,9 @@ void SdTiledRenderingTest::testDisableUndoRepair() pView1->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem1); pView2->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem2); CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item* >(pItem1.get())); - CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(pItem2.get())); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item * >(pItem2.get())->GetValue()); + const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item*>(pItem2.get()); + CPPUNIT_ASSERT(pUInt32Item); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pUInt32Item->GetValue()); } // Insert a character in the second view. @@ -1818,8 +1820,9 @@ void SdTiledRenderingTest::testDisableUndoRepair() pView1->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem1); pView2->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem2); CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item* >(pItem2.get())); - CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(pItem1.get())); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item * >(pItem1.get())->GetValue()); + const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item*>(pItem1.get()); + CPPUNIT_ASSERT(pUInt32Item); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pUInt32Item->GetValue()); } } diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 8bf0f359c288..1d5926c33a88 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1740,8 +1740,9 @@ void checkUndoRepairStates(SwXTextDocument* pXTextDocument, SwView* pView1, SwVi // second view, undo conflict pView2->GetState(aItemSet2); CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aItemSet2.GetItemState(SID_UNDO)); - CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO))); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO))->GetValue()); + const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item*>(aItemSet2.GetItem(SID_UNDO)); + CPPUNIT_ASSERT(pUInt32Item); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pUInt32Item->GetValue()); }; } |