From 3123c597c863b362b251add2c98d77167fc53f18 Mon Sep 17 00:00:00 2001 From: Nischal Sheth Date: Wed, 29 Jun 2016 10:23:59 -0700 Subject: [PATCH] Fix PeerManager::NextPeer to take parameter by const reference Change-Id: I343b37b019860cac1c6db4533d589f08d8a9a2a6 Partial-Bug: 1548570 --- src/bgp/bgp_show_neighbor.cc | 2 +- src/bgp/routing-instance/peer_manager.cc | 15 ++------------- src/bgp/routing-instance/peer_manager.h | 3 +-- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/bgp/bgp_show_neighbor.cc b/src/bgp/bgp_show_neighbor.cc index 1dd141a408b..b4c8b4e945a 100644 --- a/src/bgp/bgp_show_neighbor.cc +++ b/src/bgp/bgp_show_neighbor.cc @@ -28,7 +28,7 @@ static bool FillBgpNeighborInfoList(const BgpSandeshContext *bsc, rtinstance->peer_manager()->FillBgpNeighborInfo( bsc, show_list, search_string, summary); - BgpPeer *peer = bsc->bgp_server->FindNextPeer(); + const BgpPeer *peer = bsc->bgp_server->FindNextPeer(); while (peer) { if (search_string.empty() || (peer->peer_basename().find(search_string) != string::npos) || diff --git a/src/bgp/routing-instance/peer_manager.cc b/src/bgp/routing-instance/peer_manager.cc index 2a921f8843e..3ee7866aaaf 100644 --- a/src/bgp/routing-instance/peer_manager.cc +++ b/src/bgp/routing-instance/peer_manager.cc @@ -239,22 +239,10 @@ BgpPeer *PeerManager::PeerLookup(TcpSession::Endpoint remote_endpoint) const { return peer; } -BgpPeer *PeerManager::NextPeer(BgpPeerKey &peer_key) { - // Do a partial match - BgpPeerKeyMap::iterator loc = peers_by_key_.upper_bound(peer_key); - if (loc != peers_by_key_.end()) { - peer_key = loc->second->peer_key(); - return loc->second; - } - - return NULL; -} - -const BgpPeer *PeerManager::NextPeer(BgpPeerKey &peer_key) const { +const BgpPeer *PeerManager::NextPeer(const BgpPeerKey &peer_key) const { // Do a partial match BgpPeerKeyMap::const_iterator loc = peers_by_key_.upper_bound(peer_key); if (loc != peers_by_key_.end()) { - peer_key = loc->second->peer_key(); return loc->second; } @@ -282,5 +270,6 @@ void PeerManager::FillBgpNeighborInfo(const BgpSandeshContext *bsc, peer->FillNeighborInfo(bsc, &bnr, summary); bnr_list->push_back(bnr); } + key = peer->peer_key(); } } diff --git a/src/bgp/routing-instance/peer_manager.h b/src/bgp/routing-instance/peer_manager.h index da51505cade..fc0a9013afd 100644 --- a/src/bgp/routing-instance/peer_manager.h +++ b/src/bgp/routing-instance/peer_manager.h @@ -39,8 +39,7 @@ class PeerManager { virtual void DestroyIPeer(IPeer *ipeer); void ClearAllPeers(); - virtual BgpPeer *NextPeer(BgpPeerKey &key); - virtual const BgpPeer *NextPeer(BgpPeerKey &key) const; + const BgpPeer *NextPeer(const BgpPeerKey &key) const; void FillBgpNeighborInfo(const BgpSandeshContext *bsc, std::vector *sbnr_list,