From: Andreas Hansson Date: Fri, 19 Sep 2014 14:35:11 +0000 (-0400) Subject: misc: Use safe_cast when assumptions are made about return value X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=efd5cf323ab9ba91487d975899f13353d3258e83;p=gem5.git misc: Use safe_cast when assumptions are made about return value This patch changes two dynamic_cast to safe_cast as we assume the return value is not NULL (without checking). --- diff --git a/src/cpu/testers/memtest/memtest.cc b/src/cpu/testers/memtest/memtest.cc index 6dc2ccb73..d949178c2 100644 --- a/src/cpu/testers/memtest/memtest.cc +++ b/src/cpu/testers/memtest/memtest.cc @@ -170,7 +170,7 @@ MemTest::completeRequest(PacketPtr pkt) pkt->isError() ? "error" : "success"); MemTestSenderState *state = - dynamic_cast(pkt->senderState); + safe_cast(pkt->senderState); uint8_t *data = state->data; uint8_t *pkt_data = pkt->getPtr(); diff --git a/src/mem/packet.cc b/src/mem/packet.cc index 5b0834285..8bbd7ff18 100644 --- a/src/mem/packet.cc +++ b/src/mem/packet.cc @@ -189,7 +189,7 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size, // check print first since it doesn't require data if (isPrint()) { - dynamic_cast(senderState)->printObj(obj); + safe_cast(senderState)->printObj(obj); return false; }