Merge pull request #2054 from qlyoung/sa-fixes

Static analyzer fixes
This commit is contained in:
Renato Westphal 2018-04-15 19:10:50 -03:00 committed by GitHub
commit aecba4e88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 54 additions and 65 deletions

View File

@ -176,6 +176,7 @@ insert_route(struct babel_route *route)
resize_route_table(max_route_slots < 1 ? 8 : 2 * max_route_slots);
if(route_slots >= max_route_slots)
return NULL;
assert(routes);
route->next = NULL;
if(n < route_slots)
memmove(routes + n + 1, routes + n,

View File

@ -592,6 +592,8 @@ void bgp_info_mpath_update(struct bgp_node *rn, struct bgp_info *new_best,
*/
new_mpath = listgetdata(mp_node);
list_delete_node(mp_list, mp_node);
assert(new_mpath);
assert(prev_mpath);
if ((mpath_count < maxpaths) && (new_mpath != new_best)
&& bgp_info_nexthop_cmp(prev_mpath, new_mpath)) {
if (new_mpath == next_mpath)

View File

@ -649,7 +649,6 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
uint8_t sub_code, uint8_t *data, size_t datalen)
{
struct stream *s;
int length;
/* Lock I/O mutex to prevent other threads from pushing packets */
pthread_mutex_lock(&peer->io_mtx);
@ -670,7 +669,7 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
stream_write(s, data, datalen);
/* Set BGP packet length. */
length = bgp_packet_set_size(s);
bgp_packet_set_size(s);
/* wipe output buffer */
stream_fifo_clean(peer->obuf);
@ -697,13 +696,13 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
bgp_notify.code = code;
bgp_notify.subcode = sub_code;
bgp_notify.data = NULL;
bgp_notify.length = length - BGP_MSG_NOTIFY_MIN_SIZE;
bgp_notify.length = datalen;
bgp_notify.raw_data = data;
peer->notify.code = bgp_notify.code;
peer->notify.subcode = bgp_notify.subcode;
if (bgp_notify.length) {
if (bgp_notify.length && data) {
bgp_notify.data =
XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
for (i = 0; i < bgp_notify.length; i++)

View File

@ -7047,18 +7047,20 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
default:
vty_out(vty, "?");
}
}
struct eth_segment_id *id = &(attr->evpn_overlay.eth_s_id);
char *str = esi2str(id);
char *str = esi2str(&(attr->evpn_overlay.eth_s_id));
vty_out(vty, "%s", str);
XFREE(MTYPE_TMP, str);
if (IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p)) {
vty_out(vty, "/%s", inet_ntoa(attr->evpn_overlay.gw_ip.ipv4));
vty_out(vty, "/%s",
inet_ntoa(attr->evpn_overlay.gw_ip.ipv4));
} else if (IS_EVPN_PREFIX_IPADDR_V6((struct prefix_evpn *)p)) {
vty_out(vty, "/%s",
inet_ntop(AF_INET6, &(attr->evpn_overlay.gw_ip.ipv6),
buf, BUFSIZ));
inet_ntop(AF_INET6,
&(attr->evpn_overlay.gw_ip.ipv6), buf,
BUFSIZ));
}
if (attr->ecommunity) {
char *mac = NULL;
@ -7075,6 +7077,8 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
vty_out(vty, "\n");
}
}
/* dampening route */
static void damp_route_vty_out(struct vty *vty, struct prefix *p,
struct bgp_info *binfo, int display, safi_t safi,

View File

@ -548,13 +548,12 @@ rfapi_group_new(struct bgp *bgp, rfapi_group_cfg_type_t type, const char *name)
rfg = XCALLOC(MTYPE_RFAPI_GROUP_CFG,
sizeof(struct rfapi_nve_group_cfg));
if (rfg) {
rfg->type = type;
rfg->name = strdup(name);
/* add to tail of list */
listnode_add(bgp->rfapi_cfg->nve_groups_sequential, rfg);
}
rfg->label = MPLS_LABEL_NONE;
QOBJ_REG(rfg, rfapi_nve_group_cfg);
return rfg;

View File

@ -23,6 +23,9 @@
*/
%{
/* ignore flex generated code in static analyzer */
#ifndef __clang_analyzer__
/* ignore harmless bugs in old versions of flex */
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
@ -91,3 +94,5 @@ void cleanup_lexer (yyscan_t *scn)
// yy_delete_buffer (buffer, *scn);
yylex_destroy(*scn);
}
#endif /* __clang_analyzer__ */

View File

@ -99,6 +99,9 @@ enum matcher_rv command_match(struct graph *cmdgraph, vector vline,
struct listnode *head = listhead(*argv);
struct listnode *tail = listtail(*argv);
assert(head);
assert(tail);
// delete dummy start node
cmd_token_del((struct cmd_token *)head->data);
list_delete_node(*argv, head);

View File

@ -786,6 +786,9 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
/* (3) if the prefix is equal to an active configured address range */
/* or if the NU bit is set in the prefix */
if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_PREFIX)) {
/* must have been set in previous block */
assert(prefix_lsa);
range = ospf6_route_lookup(&prefix, oa->range_table);
if (range) {
if (is_debug)

View File

@ -349,28 +349,6 @@ void ospf6_interface_if_add(struct interface *ifp)
ospf6_interface_state_update(oi->interface);
}
void ospf6_interface_if_del(struct interface *ifp)
{
struct ospf6_interface *oi;
oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL)
return;
/* interface stop */
if (oi->area)
thread_execute(master, interface_down, oi, 0);
listnode_delete(oi->area->if_list, oi);
oi->area = (struct ospf6_area *)NULL;
/* cut link */
oi->interface = NULL;
ifp->info = NULL;
ospf6_interface_delete(oi);
}
void ospf6_interface_state_update(struct interface *ifp)
{
struct ospf6_interface *oi;

View File

@ -176,7 +176,6 @@ extern void ospf6_interface_enable(struct ospf6_interface *);
extern void ospf6_interface_disable(struct ospf6_interface *);
extern void ospf6_interface_if_add(struct interface *);
extern void ospf6_interface_if_del(struct interface *);
extern void ospf6_interface_state_update(struct interface *);
extern void ospf6_interface_connected_route_update(struct interface *);

View File

@ -1844,6 +1844,7 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa)
INTRA_PREFIX)) {
prefix2str(&route->prefix, buf,
sizeof(buf));
assert(route->nh_list);
zlog_debug("%s: route %s update paths %u nh %u"
, __PRETTY_FUNCTION__,
buf,

View File

@ -127,13 +127,6 @@ static int ospf6_zebra_if_del(int command, struct zclient *zclient,
zlog_debug("Zebra Interface delete: %s index %d mtu %d",
ifp->name, ifp->ifindex, ifp->mtu6);
#if 0
/* XXX: ospf6_interface_if_del is not the right way to handle this,
* because among other thinkable issues, it will also clear all
* settings as they are contained in the struct ospf6_interface. */
ospf6_interface_if_del (ifp);
#endif /*0*/
if_set_index(ifp, IFINDEX_INTERNAL);
return 0;
}

View File

@ -1756,6 +1756,7 @@ static struct ospf_lsa *ospf_lsa_translated_nssa_new(struct ospf *ospf,
ei.route_map_set.metric = -1;
ei.route_map_set.metric_type = -1;
ei.tag = 0;
ei.instance = 0;
if ((new = ospf_external_lsa_new(ospf, &ei, &type7->data->id))
== NULL) {

View File

@ -118,7 +118,8 @@ static int ospf_interface_add(int command, struct zclient *zclient,
assert(ifp->info);
if (!OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type)) {
if (IF_DEF_PARAMS(ifp)
&& !OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type)) {
SET_IF_PARAM(IF_DEF_PARAMS(ifp), type);
IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
}