From 8cea9547754f0a8f678ecc45c895a23e2e791332 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 4 Dec 2017 21:26:57 -0500 Subject: [PATCH] bgpd: Cleanup unneeded NULL checks. All the NULL checks come after previous dereferences. Signed-off-by: Donald Sharp --- bgpd/rfapi/rfapi_import.c | 4 ++-- bgpd/rfapi/rfapi_rib.c | 15 ++++++--------- bgpd/rfapi/rfapi_vty.c | 4 ++-- bgpd/rfapi/vnc_import_bgp.c | 4 ++-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index cdbc88c967..87c4509c49 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -1452,7 +1452,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, __func__, __LINE__, have_vnc_tunnel_un); #endif - if (!have_vnc_tunnel_un && bi && bi->extra) { + if (!have_vnc_tunnel_un && bi->extra) { /* * use cached UN address from ENCAP route */ @@ -3947,7 +3947,7 @@ void rfapiProcessUpdate(struct peer *peer, vnc_zlog_debug_verbose( "%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p", __func__, rc, lni, attr); - if (attr && !rc) { + if (!rc) { it = rfapiMacImportTableGet(bgp, lni); rfapiBgpInfoFilteredImportVPN( diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 36ae6e7273..8d77cfa7d8 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -207,7 +207,7 @@ void rfapiRibCheckCounts( } } - if (checkstats && bgp && bgp->rfapi) { + if (checkstats && bgp->rfapi) { if (t_pfx_active != bgp->rfapi->rib_prefix_count_total) { vnc_zlog_debug_verbose( "%s: actual total pfx count %u != running %u", @@ -688,13 +688,10 @@ static void rfapiRibBi2Ri(struct bgp_info *bi, struct rfapi_info *ri, memcpy(&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val + 2, ETH_ALEN); - if (bi->attr) { - (void)rfapiEcommunityGetLNI( - bi->attr->ecommunity, - &vo->v.l2addr.logical_net_id); - (void)rfapiEcommunityGetEthernetTag( - bi->attr->ecommunity, &vo->v.l2addr.tag_id); - } + (void)rfapiEcommunityGetLNI(bi->attr->ecommunity, + &vo->v.l2addr.logical_net_id); + (void)rfapiEcommunityGetEthernetTag(bi->attr->ecommunity, + &vo->v.l2addr.tag_id); /* local_nve_id comes from RD */ vo->v.l2addr.local_nve_id = bi->extra->vnc.import.rd.val[1]; @@ -710,7 +707,7 @@ static void rfapiRibBi2Ri(struct bgp_info *bi, struct rfapi_info *ri, /* * If there is an auxiliary IP address (L2 can have it), copy it */ - if (bi && bi->extra && bi->extra->vnc.import.aux_prefix.family) { + if (bi->extra && bi->extra->vnc.import.aux_prefix.family) { ri->rk.aux_prefix = bi->extra->vnc.import.aux_prefix; } } diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 6af99278bc..3cd83a957e 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -1146,7 +1146,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, char buf_age[BUFSIZ]; - if (bi && bi->extra && bi->extra->vnc.import.create_time) { + if (bi->extra && bi->extra->vnc.import.create_time) { rfapiFormatAge(bi->extra->vnc.import.create_time, buf_age, BUFSIZ); } else { @@ -1163,7 +1163,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, * print that on the next line */ - if (bi && bi->extra + if (bi->extra && bi->extra->vnc.import.aux_prefix.family) { const char *sp; diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index bec0b9e6c6..d61a6c4285 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -1451,7 +1451,7 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( return; } - if (bgp && bgp->rfapi) + if (bgp->rfapi) sl = bgp->rfapi->resolve_nve_nexthop; if (!sl) { @@ -1598,7 +1598,7 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( return; } - if (bgp && bgp->rfapi) + if (bgp->rfapi) sl = bgp->rfapi->resolve_nve_nexthop; if (!sl) { -- 2.39.5