diff --git a/src/routing/olsr/olsr-agent-impl.cc b/src/routing/olsr/olsr-agent-impl.cc index 79b5ae02c..614bf5dff 100644 --- a/src/routing/olsr/olsr-agent-impl.cc +++ b/src/routing/olsr/olsr-agent-impl.cc @@ -572,12 +572,15 @@ AgentImpl::MprComputation() // (not in RFC but I think is needed: remove the 2-hop // neighbors reachable by the MPR from N2) for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); - twoHopNeigh != N2.end (); twoHopNeigh++) + twoHopNeigh != N2.end (); ) { if (twoHopNeigh->neighborMainAddr == neighbor->neighborMainAddr) { twoHopNeigh = N2.erase (twoHopNeigh); - twoHopNeigh--; + } + else + { + twoHopNeigh++; } } } @@ -617,12 +620,15 @@ AgentImpl::MprComputation() } // Remove the nodes from N2 which are now covered by a node in the MPR set. for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); - twoHopNeigh != N2.end (); twoHopNeigh++) + twoHopNeigh != N2.end (); ) { if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ()) { twoHopNeigh = N2.erase (twoHopNeigh); - twoHopNeigh--; + } + else + { + twoHopNeigh++; } } @@ -699,12 +705,15 @@ AgentImpl::MprComputation() { mprSet.insert (max->neighborMainAddr); for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); - twoHopNeigh != N2.end (); twoHopNeigh++) + twoHopNeigh != N2.end (); ) { if (twoHopNeigh->neighborMainAddr == max->neighborMainAddr) { twoHopNeigh = N2.erase (twoHopNeigh); - twoHopNeigh--; + } + else + { + twoHopNeigh++; } } } diff --git a/src/routing/olsr/olsr-state.cc b/src/routing/olsr/olsr-state.cc index 545407a4b..ad4cb8723 100644 --- a/src/routing/olsr/olsr-state.cc +++ b/src/routing/olsr/olsr-state.cc @@ -64,12 +64,15 @@ void OlsrState::EraseMprSelectorTuples (const Ipv4Address &mainAddr) { for (MprSelectorSet::iterator it = m_mprSelectorSet.begin (); - it != m_mprSelectorSet.end (); it++) + it != m_mprSelectorSet.end ();) { if (it->mainAddr == mainAddr) { it = m_mprSelectorSet.erase (it); - it--; + } + else + { + it++; } } } @@ -203,15 +206,18 @@ OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr, const Ipv4Address &twoHopNeighborAddr) { for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin (); - it != m_twoHopNeighborSet.end (); it++) + it != m_twoHopNeighborSet.end ();) { if (it->neighborMainAddr == neighborMainAddr && it->twoHopNeighborAddr == twoHopNeighborAddr) { it = m_twoHopNeighborSet.erase (it); - it--; // FIXME: is this correct in the case 'it' pointed to the first element? m_modified = true; } + else + { + it++; + } } } @@ -219,13 +225,17 @@ void OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr) { for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin (); - it != m_twoHopNeighborSet.end (); it++) + it != m_twoHopNeighborSet.end ();) { - if (it->neighborMainAddr == neighborMainAddr) { - it = m_twoHopNeighborSet.erase (it); - it--; - m_modified = true; - } + if (it->neighborMainAddr == neighborMainAddr) + { + it = m_twoHopNeighborSet.erase (it); + m_modified = true; + } + else + { + it++; + } } } @@ -385,14 +395,17 @@ void OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn) { for (TopologySet::iterator it = m_topologySet.begin(); - it != m_topologySet.end(); it++) + it != m_topologySet.end();) { if (it->lastAddr == lastAddr && it->sequenceNumber < ansn) { it = m_topologySet.erase (it); - it--; m_modified = true; } + else + { + it++; + } } }