Skip to content

Redundant variable declarations (variable shadowing) in createNodeFromXML #1153

@doguto

Description

@doguto

In src/xml_parsing.cpp, inside XMLParser::PImpl::createNodeFromXML(), port_name and port_value are declared twice within the same loop iteration. The outer declarations (lines 805–806) are immediately shadowed by identical re-declarations inside the if(IsAllowedPortName(port_name)) block (lines 809–810):

for(const XMLAttribute* att = element->FirstAttribute(); att != nullptr; att = att->Next())
{
  const std::string port_name = att->Name();   // declared here
  const std::string port_value = att->Value(); // declared here
  if(IsAllowedPortName(port_name))
  {
    const std::string port_name = att->Name();   // redundant — shadows outer
    const std::string port_value = att->Value(); // redundant — shadows outer
    ...
  }
}

The inner variables have exactly the same values as the outer ones and serve no purpose. The fix is to remove lines 809–810.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions