diff options
author | Maria Matejka <mq@ucw.cz> | 2020-05-01 15:34:17 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2020-05-01 15:34:17 +0200 |
commit | 048eb2ddf1ee9587d9fa30cbb3f87d6f650a2133 (patch) | |
tree | fdec4c5679a02c901cf2bc92fd81618c6f12d48e /proto/ospf | |
parent | 17de3a023f7bde293892b41bfafe5740c8553fc8 (diff) | |
parent | 59238768b3b05fa134348d2232b42537d0403994 (diff) |
Merge remote-tracking branch 'origin/mq-static-analysis'
Diffstat (limited to 'proto/ospf')
-rw-r--r-- | proto/ospf/neighbor.c | 19 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 8 | ||||
-rw-r--r-- | proto/ospf/topology.c | 8 |
3 files changed, 23 insertions, 12 deletions
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index 30e80640..18692d6e 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -650,19 +650,20 @@ void ospf_dr_election(struct ospf_iface *ifa) { struct ospf_proto *p = ifa->oa->po; - struct ospf_neighbor *neigh, *ndr, *nbdr, me; + struct ospf_neighbor *neigh, *ndr, *nbdr; u32 myid = p->router_id; DBG("(B)DR election.\n"); - me.state = NEIGHBOR_2WAY; - me.rid = myid; - me.priority = ifa->priority; - me.ip = ifa->addr->ip; - - me.dr = ospf_is_v2(p) ? ipa_to_u32(ifa->drip) : ifa->drid; - me.bdr = ospf_is_v2(p) ? ipa_to_u32(ifa->bdrip) : ifa->bdrid; - me.iface_id = ifa->iface_id; + struct ospf_neighbor me = { + .state = NEIGHBOR_2WAY, + .rid = myid, + .priority = ifa->priority, + .ip = ifa->addr->ip, + .dr = ospf_is_v2(p) ? ipa_to_u32(ifa->drip) : ifa->drid, + .bdr = ospf_is_v2(p) ? ipa_to_u32(ifa->bdrip) : ifa->bdrid, + .iface_id = ifa->iface_id, + }; add_tail(&ifa->neigh_list, NODE & me); diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 29610f4a..c8ed0e06 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -620,7 +620,7 @@ ospf_get_route_info(rte * rte, byte * buf) } static int -ospf_get_attr(eattr * a, byte * buf, int buflen UNUSED) +ospf_get_attr(const eattr * a, byte * buf, int buflen UNUSED) { switch (a->id) { @@ -1244,7 +1244,7 @@ ospf_sh_state(struct proto *P, int verbose, int reachable) uint num = p->gr->hash_entries; struct top_hash_entry *hea[num]; - struct top_hash_entry *hex[verbose ? num : 0]; + struct top_hash_entry **hex = verbose ? alloca(num * sizeof(struct top_hash_entry *)) : NULL; struct top_hash_entry *he; struct top_hash_entry *cnode = NULL; @@ -1289,7 +1289,9 @@ ospf_sh_state(struct proto *P, int verbose, int reachable) lsa_compare_ospf3 = !ospf2; qsort(hea, j1, sizeof(struct top_hash_entry *), lsa_compare_for_state); - qsort(hex, jx, sizeof(struct top_hash_entry *), ext_compare_for_state); + + if (verbose) + qsort(hex, jx, sizeof(struct top_hash_entry *), ext_compare_for_state); /* * This code is a bit tricky, we have a primary LSAs (router and diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index 2e9c3965..c8ec730a 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -329,6 +329,14 @@ ospf_originate_lsa(struct ospf_proto *p, struct ospf_new_lsa *lsa) en->next_lsa_opts = 0; } + /* The static analyzer complains here that en->lsa_body may be NULL. + * Yes, it may if ospf_hash_get() creates a new struct top_hash_entry. + * In this case, also en->lsa.length must be 0 and lsa_length is never + * equal to 0 while sizeof(struct ospf_lsa_header) is non-zero. + * Therefore memcmp() is never executed with NULL here. + * */ + ASSUME((en->lsa.length == 0) == (en->lsa_body == NULL)); + /* Ignore the the new LSA if is the same as the current one */ if ((en->lsa.age < LSA_MAXAGE) && (lsa_length == en->lsa.length) && |