Ticket #10224: 0001-Changed-unchecked-dynamic-casts-to-reinterpret-casts.patch

File 0001-Changed-unchecked-dynamic-casts-to-reinterpret-casts.patch, 4.5 KB (added by Ezodev, 6 years ago)
  • src/apps/debugger/arch/x86/ArchitectureX86.cpp

    From c6f73bb892a200dec4599d982538230ee70bc0cf Mon Sep 17 00:00:00 2001
    From: Ezo <ezo.dev@gmail.com>
    Date: Tue, 19 Nov 2013 22:57:40 +0000
    Subject: [PATCH] Changed unchecked dynamic casts to reinterpret casts. Dynamic
     casts is useless if there is no checking. It's slower than reinterpret casts
     too.
    
    ---
     src/apps/debugger/arch/x86/ArchitectureX86.cpp             | 2 +-
     src/apps/debugger/model/Type.cpp                           | 2 +-
     src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp | 2 +-
     src/apps/debugger/value/value_nodes/ArrayValueNode.cpp     | 2 +-
     src/apps/debugger/value/value_nodes/BMessageValueNode.cpp  | 6 +++---
     5 files changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/src/apps/debugger/arch/x86/ArchitectureX86.cpp b/src/apps/debugger/arch/x86/ArchitectureX86.cpp
    index b0bec17..15c4ffb 100644
    a b ArchitectureX86::UpdateStackFrameCpuState(const StackFrame* frame, 
    415415{
    416416    // This is not a top frame, so we want to offset eip to the previous
    417417    // (calling) instruction.
    418     CpuStateX86* cpuState = dynamic_cast<CpuStateX86*>(previousCpuState);
     418    CpuStateX86* cpuState = reinterpret_cast<CpuStateX86*>(previousCpuState);
    419419
    420420    // get eip
    421421    uint32 eip = cpuState->IntRegisterValue(X86_REGISTER_EIP);
  • src/apps/debugger/model/Type.cpp

    diff --git a/src/apps/debugger/model/Type.cpp b/src/apps/debugger/model/Type.cpp
    index 318abf2..34d4f9b 100644
    a b ArrayDimension::CountElements() const 
    4848        return dynamic_cast<EnumerationType*>(type)->CountValues();
    4949
    5050    if (type->Kind() == TYPE_SUBRANGE) {
    51         SubrangeType* subrangeType = dynamic_cast<SubrangeType*>(type);
     51        SubrangeType* subrangeType = reinterpret_cast<SubrangeType*>(type);
    5252        BVariant lower = subrangeType->LowerBound();
    5353        BVariant upper = subrangeType->UpperBound();
    5454        bool isSigned;
  • src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp

    diff --git a/src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp b/src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp
    index 6165eef..1706c7a 100644
    a b public: 
    175175        Settings* settings)
    176176    {
    177177        SettingsOption* selectedOption = settings->OptionValue(
    178             dynamic_cast<OptionsSetting*>(GetSetting()));
     178            reinterpret_cast<OptionsSetting*>(GetSetting()));
    179179
    180180        for (int32 i = 0; BMenuItem* item = Submenu()->ItemAt(i); i++) {
    181181            OptionMenuItem* optionItem = dynamic_cast<OptionMenuItem*>(item);
  • src/apps/debugger/value/value_nodes/ArrayValueNode.cpp

    diff --git a/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp b/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp
    index bc05323..a809556 100644
    a b ArrayValueNodeChild::ResolveLocation(ValueLoader* valueLoader, 
    313313    for (int32 i = dimensionCount - 1; i >= 0; i--) {
    314314        indexPath.SetIndexAt(i, child->ElementIndex());
    315315
    316         child = dynamic_cast<AbstractArrayValueNodeChild*>(
     316        child = reinterpret_cast<AbstractArrayValueNodeChild*>(
    317317            child->ArrayParent()->NodeChild());
    318318    }
    319319
  • src/apps/debugger/value/value_nodes/BMessageValueNode.cpp

    diff --git a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp
    index 0da34fe..94f0563 100644
    a b public: 
    6969    {
    7070        ValueLocation* parentLocation = fParent->Location();
    7171        ValueLocation* location;
    72         CompoundType* type = dynamic_cast<CompoundType*>(fParent->GetType());
     72        CompoundType* type = reinterpret_cast<CompoundType*>(fParent->GetType());
    7373        status_t error = B_OK;
    7474        if (fParent->fIsFlatMessage) {
    7575            location = new ValueLocation();
    BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, 
    174174    BVariant fieldAddress;
    175175    BVariant what;
    176176
    177     CompoundType* baseType = dynamic_cast<CompoundType*>(fType);
     177    CompoundType* baseType = reinterpret_cast<CompoundType*>(fType);
    178178
    179179    if (fIsFlatMessage) {
    180180        headerAddress.SetTo(location->PieceAt(0).address);
    status_t 
    333333BMessageValueNode::CreateChildren()
    334334{
    335335    DataMember* member = NULL;
    336     CompoundType* messageType = dynamic_cast<CompoundType*>(fType);
     336    CompoundType* messageType = reinterpret_cast<CompoundType*>(fType);
    337337    for (int32 i = 0; i < messageType->CountDataMembers(); i++) {
    338338        member = messageType->DataMemberAt(i);
    339339        if (strcmp(member->Name(), "what") == 0) {