From 1b7e171b246a38154557c509ad1b42f96ea3a585 Mon Sep 17 00:00:00 2001 From: Nischal Sheth Date: Wed, 20 May 2015 18:05:21 -0700 Subject: [PATCH] Get rid of a few unnecessary asserts Change-Id: I9e165d91c5c5485e908f44bee41688c52899c2d2 Partial-Bug: 1456193 --- src/bgp/bgp_config.cc | 10 +++++++--- src/bgp/routing-instance/routing_instance.cc | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bgp/bgp_config.cc b/src/bgp/bgp_config.cc index 78279e91dc6..9322ae5014e 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -503,7 +503,8 @@ static void GetRoutingInstanceExportTargets(DBGraph *graph, IFMapNode *node, (GetInstanceTargetRouteTarget(graph, adj, &target))) { const autogen::InstanceTarget *itarget = dynamic_cast(adj->GetObject()); - assert(itarget); + if (!itarget) + continue; const autogen::InstanceTargetType &itt = itarget->data(); if (itt.import_export != "import") target_list->push_back(target); @@ -583,7 +584,8 @@ void BgpInstanceConfig::Update(BgpConfigManager *manager, if (GetInstanceTargetRouteTarget(graph, adj, &target)) { const autogen::InstanceTarget *itarget = dynamic_cast(adj->GetObject()); - assert(itarget); + if (!itarget) + continue; const autogen::InstanceTargetType &itt = itarget->data(); if (itt.import_export == "import") { import_list_.insert(target); @@ -1179,7 +1181,9 @@ void BgpConfigManager::ProcessBgpPeering(const BgpConfigDelta &delta) { event = BgpConfigManager::CFG_ADD; string instance_name(IdentifierParent(routers.first->name())); BgpInstanceConfig *rti = config_->FindInstance(instance_name); - assert(rti != NULL); + if (rti == NULL) { + return; + } peering = config_->CreatePeering(rti, proxy); } else { const IFMapNode *node = peering->node(); diff --git a/src/bgp/routing-instance/routing_instance.cc b/src/bgp/routing-instance/routing_instance.cc index 6aa0735b3a1..dcbc8de0b66 100644 --- a/src/bgp/routing-instance/routing_instance.cc +++ b/src/bgp/routing-instance/routing_instance.cc @@ -315,7 +315,7 @@ void RoutingInstanceMgr::UpdateRoutingInstance( RTINSTANCE_LOG_MESSAGE(server_, SandeshLevel::SYS_WARN, RTINSTANCE_LOG_FLAG_ALL, config->name(), "Instance not found during update"); - assert(rtinstance != NULL); + return; } InstanceTargetRemove(rtinstance); @@ -362,7 +362,7 @@ void RoutingInstanceMgr::DeleteRoutingInstance(const string &name) { RTINSTANCE_LOG_MESSAGE(server_, SandeshLevel::SYS_WARN, RTINSTANCE_LOG_FLAG_ALL, name, "Instance not found during delete"); - assert(rtinstance != NULL); + return; } InstanceVnIndexRemove(rtinstance);