From 21e551fece825676d051ba8bd46fdf9deb900ee7 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 cea403ed553..7108d5b3003 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -488,7 +488,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); @@ -568,7 +569,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); @@ -1164,7 +1166,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 d81a2de9562..2310955d942 100644 --- a/src/bgp/routing-instance/routing_instance.cc +++ b/src/bgp/routing-instance/routing_instance.cc @@ -313,7 +313,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); @@ -360,7 +360,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);