From 266469ebababa2d6949bbd22390010d422a68356 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 20 Aug 2018 14:05:53 -0400 Subject: [PATCH] ospfd: Cleanup some warnings that were not warnings 1) stream allocation cannot fail 2) some warnings were removed when functions safely ignored the calling parameters being wrong. 3) some warnings were removed when functions did not consider the state as an error since we did not return an error code. Signed-off-by: Donald Sharp --- ospfd/ospf_ext.c | 10 ---------- ospfd/ospf_interface.c | 2 +- ospfd/ospf_lsa.c | 9 +-------- ospfd/ospf_lsdb.c | 13 +------------ ospfd/ospf_ri.c | 6 ++---- ospfd/ospf_sr.c | 11 ++--------- ospfd/ospf_te.c | 9 +++------ ospfd/ospf_zebra.c | 4 ---- ospfd/ospfd.c | 8 ++------ 9 files changed, 12 insertions(+), 60 deletions(-) diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index f6ed9b81b9..25b27d442b 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -538,8 +538,6 @@ static int ospf_ext_link_new_if(struct interface *ifp) int rc = -1; if (lookup_ext_by_ifp(ifp) != NULL) { - zlog_warn("EXT (%s): interface %s is already in use", __func__, - ifp ? ifp->name : "-"); rc = 0; /* Do nothing here. */ return rc; } @@ -929,10 +927,6 @@ static struct ospf_lsa *ospf_ext_pref_lsa_new(struct ospf_area *area, /* Create a stream for LSA. */ s = stream_new(OSPF_MAX_LSA_SIZE); - if (s == NULL) { - zlog_warn("EXT (%s): stream_new() error", __func__); - return NULL; - } /* Prepare LSA Header */ lsah = (struct lsa_header *)STREAM_DATA(s); @@ -1007,10 +1001,6 @@ static struct ospf_lsa *ospf_ext_link_lsa_new(struct ospf_area *area, /* Create a stream for LSA. */ s = stream_new(OSPF_MAX_LSA_SIZE); - if (s == NULL) { - zlog_warn("EXT (%s): stream_new() error", __func__); - return NULL; - } lsah = (struct lsa_header *)STREAM_DATA(s); options = OSPF_OPTION_O; /* Don't forget this :-) */ diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 24584f6713..2ad36ae364 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -1033,7 +1033,7 @@ static int ospf_vl_set_params(struct ospf_vl_data *vl_data, struct vertex *v) * there should be due to the ospf_spf_has_link() check * in SPF. Lets warn and try pick a link anyway. */ - zlog_warn("ospf_vl_set_params: No backlink for %s!", + zlog_info("ospf_vl_set_params: No backlink for %s!", vl_data->vl_oi->ifp->name); for (i = 0; i < ntohs(rl->links); i++) { switch (rl->link[i].type) { diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 7c8a68994f..c3c720b678 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -2522,15 +2522,8 @@ void ospf_discard_from_db(struct ospf *ospf, struct ospf_lsdb *lsdb, { struct ospf_lsa *old; - if (!lsdb) { - zlog_warn("%s: Called with NULL lsdb!", __func__); - if (!lsa) - zlog_warn("%s: and NULL LSA!", __func__); - else - zlog_warn("LSA[Type%d:%s]: not associated with LSDB!", - lsa->data->type, inet_ntoa(lsa->data->id)); + if (!lsdb) return; - } old = ospf_lsdb_lookup(lsdb, lsa); diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c index ef965a5f91..f39bea9768 100644 --- a/ospfd/ospf_lsdb.c +++ b/ospfd/ospf_lsdb.c @@ -142,19 +142,8 @@ void ospf_lsdb_delete(struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) struct prefix_ls lp; struct route_node *rn; - if (!lsdb) { - zlog_warn("%s: Called with NULL LSDB", __func__); - if (lsa) - zlog_warn("LSA[Type%d:%s]: LSA %p, lsa->lsdb %p", - lsa->data->type, inet_ntoa(lsa->data->id), - (void *)lsa, (void *)lsa->lsdb); + if (!lsdb || !lsa) return; - } - - if (!lsa) { - zlog_warn("%s: Called with NULL LSA", __func__); - return; - } assert(lsa->data->type < OSPF_MAX_LSA); table = lsdb->type[lsa->data->type].db; diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index c9d0a53c8d..4f6e1be0f4 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -742,10 +742,8 @@ static struct ospf_lsa *ospf_router_info_lsa_new() uint16_t length; /* Create a stream for LSA. */ - if ((s = stream_new(OSPF_MAX_LSA_SIZE)) == NULL) { - zlog_warn("ospf_router_info_lsa_new: stream_new() ?"); - return NULL; - } + s = stream_new(OSPF_MAX_LSA_SIZE); + lsah = (struct lsa_header *)STREAM_DATA(s); options = OSPF_OPTION_E; /* Enable AS external as we flood RI with diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index 62eca156f5..fc8899cc85 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -233,10 +233,6 @@ static int ospf_sr_start(struct ospf *ospf) srn = hash_get(OspfSR.neighbors, (void *)&(ospf->router_id), (void *)sr_node_new); - /* Sanity Check */ - if (srn == NULL) - return rc; - /* Complete & Store self SR Node */ srn->srgb.range_size = OspfSR.srgb.range_size; srn->srgb.lower_bound = OspfSR.srgb.lower_bound; @@ -1702,10 +1698,7 @@ DEFUN(ospf_sr_enable, /* Start Segment Routing */ OspfSR.enabled = true; - if (!ospf_sr_start(ospf)) { - zlog_warn("SR: Unable to start Segment Routing. Abort!"); - return CMD_WARNING; - } + ospf_sr_start(ospf); /* Set Router Information SR parameters */ if (IS_DEBUG_OSPF_EVENT) @@ -1990,7 +1983,7 @@ DEFUN (sr_prefix_sid, * update of this Extended Prefix */ listnode_add(OspfSR.self->ext_prefix, new); - zlog_warn( + zlog_info( "Interface for prefix %s/%u not found. Deferred LSA " "flooding", inet_ntoa(p.u.prefix4), p.prefixlen); diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index a9dc1c18e3..f8722f9c86 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1146,10 +1146,7 @@ static struct ospf_lsa *ospf_mpls_te_lsa_new(struct ospf *ospf, uint16_t length; /* Create a stream for LSA. */ - if ((s = stream_new(OSPF_MAX_LSA_SIZE)) == NULL) { - zlog_warn("ospf_mpls_te_lsa_new: stream_new() ?"); - return NULL; - } + s = stream_new(OSPF_MAX_LSA_SIZE); lsah = (struct lsa_header *)STREAM_DATA(s); options = OSPF_OPTION_O; /* Don't forget this :-) */ @@ -1286,7 +1283,7 @@ static int ospf_mpls_te_lsa_originate_area(void *arg) if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) { if (CHECK_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH)) { UNSET_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH); - zlog_warn( + zlog_info( "OSPF MPLS-TE (ospf_mpls_te_lsa_originate_area): Refresh instead of Originate"); ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA); } @@ -1294,7 +1291,7 @@ static int ospf_mpls_te_lsa_originate_area(void *arg) } if (!is_mandated_params_set(lp)) { - zlog_warn( + zlog_info( "ospf_mpls_te_lsa_originate_area: Link(%s) lacks some mandated MPLS-TE parameters.", lp->ifp ? lp->ifp->name : "?"); continue; diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 8c94a8ef99..5dfea4378b 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -152,10 +152,6 @@ static int ospf_interface_delete(int command, struct zclient *zclient, if (ifp == NULL) return 0; - if (if_is_up(ifp)) - zlog_warn("Zebra: got delete of %s, but interface is still up", - ifp->name); - if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) zlog_debug( "Zebra: interface delete %s vrf %s[%u] index %d flags %llx metric %d mtu %d", diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index d311b4da6b..6a8148c623 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -308,12 +308,8 @@ static struct ospf *ospf_new(unsigned short instance, const char *name) new->lsa_refresh_interval, &new->t_lsa_refresher); new->lsa_refresher_started = monotime(NULL); - if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE + 1)) == NULL) { - zlog_err( - "ospf_new: fatal error: stream_new(%u) failed allocating ibuf", - OSPF_MAX_PACKET_SIZE + 1); - exit(1); - } + new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE + 1); + new->t_read = NULL; new->oi_write_q = list_new(); new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; -- 2.39.5