Merge pull request #314 from donaldsharp/scan-build

Scan build
This commit is contained in:
David Lamparter 2017-04-04 15:57:00 +02:00 committed by GitHub
commit 3e11c00789
13 changed files with 53 additions and 91 deletions

View File

@ -279,6 +279,10 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff),
MSG_DONTWAIT, (struct sockaddr *) &s_addr,
(socklen_t *) &addr_len);
if (bytesread < 0)
zlog_warn ("isis_recv_pdu_bcast(): recvfrom() failed");
return ISIS_WARNING;
}
/*
@ -322,10 +326,10 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
addr_len = sizeof (s_addr);
/* we can read directly to the stream */
bytesread = stream_recvfrom (circuit->rcv_stream, circuit->fd,
circuit->interface->mtu, 0,
(struct sockaddr *) &s_addr,
(socklen_t *) &addr_len);
stream_recvfrom (circuit->rcv_stream, circuit->fd,
circuit->interface->mtu, 0,
(struct sockaddr *) &s_addr,
(socklen_t *) &addr_len);
if (s_addr.sll_pkttype == PACKET_OUTGOING)
{

View File

@ -68,7 +68,6 @@ remove_excess_adjs (struct list *adjs)
if (candidate->sys_type < adj->sys_type)
{
excess = node;
candidate = adj;
continue;
}
if (candidate->sys_type > adj->sys_type)
@ -78,7 +77,6 @@ remove_excess_adjs (struct list *adjs)
if (comp > 0)
{
excess = node;
candidate = adj;
continue;
}
if (comp < 0)
@ -87,7 +85,6 @@ remove_excess_adjs (struct list *adjs)
if (candidate->circuit->circuit_id > adj->circuit->circuit_id)
{
excess = node;
candidate = adj;
continue;
}
@ -98,7 +95,6 @@ remove_excess_adjs (struct list *adjs)
if (comp > 0)
{
excess = node;
candidate = adj;
continue;
}
}

View File

@ -425,7 +425,6 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p)
nbma_natoa = NULL;
if (natted) {
nbma_natoa = nbma_addr;
nbma_addr = &p->peer->vc->remote.nbma;
}
holdtime = htons(cie->holding_time);

View File

@ -876,10 +876,8 @@ pim_igmp_read (struct thread *t)
if (errno == EINTR)
continue;
if (errno == EWOULDBLOCK || errno == EAGAIN)
{
cont = 0;
break;
}
goto done;
}
}

View File

@ -577,10 +577,8 @@ static int mroute_read(struct thread *t)
if (errno == EINTR)
continue;
if (errno == EWOULDBLOCK || errno == EAGAIN)
{
cont = 0;
break;
}
break;
if (PIM_DEBUG_MROUTE)
zlog_warn("%s: failure reading fd=%d: errno=%d: %s",
__PRETTY_FUNCTION__, fd, errno, safe_strerror(errno));

View File

@ -111,42 +111,6 @@ pim_nexthop_cache_find (struct pim_rpf *rpf)
}
static int
pim_rp_list_cmp (void *v1, void *v2)
{
struct rp_info *rp1 = (struct rp_info *) v1;
struct rp_info *rp2 = (struct rp_info *) v2;
if (rp1 == rp2)
return 0;
if (!rp1 && rp2)
return -1;
if (rp1 && !rp2)
return 1;
/*
* Sort by RP IP address
*/
if (rp1->rp.rpf_addr.u.prefix4.s_addr < rp2->rp.rpf_addr.u.prefix4.s_addr)
return -1;
if (rp1->rp.rpf_addr.u.prefix4.s_addr > rp2->rp.rpf_addr.u.prefix4.s_addr)
return 1;
/*
* Sort by group IP address
*/
if (rp1->group.u.prefix4.s_addr < rp2->group.u.prefix4.s_addr)
return -1;
if (rp1->group.u.prefix4.s_addr > rp2->group.u.prefix4.s_addr)
return 1;
return -1;
}
struct pim_nexthop_cache *
pim_nexthop_cache_add (struct pim_rpf *rpf_addr)
{
@ -462,10 +426,13 @@ pim_update_upstream_nh (struct pim_nexthop_cache *pnc)
return 0;
}
/* This API is used to parse Registered address nexthop update coming from Zebra */
void
pim_parse_nexthop_update (struct zclient *zclient, int command,
vrf_id_t vrf_id)
/*
* This API is used to parse Registered address nexthop update
* coming from Zebra
*/
int
pim_parse_nexthop_update (int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id)
{
struct stream *s;
struct prefix p;
@ -512,9 +479,16 @@ pim_parse_nexthop_update (struct zclient *zclient, int command,
zlog_debug ("%s: NHT addr %s is not in local cached DB.",
__PRETTY_FUNCTION__, buf);
}
return;
return 0;
}
}
else
{
/*
* We do not currently handle ZEBRA_IMPORT_CHECK_UPDATE
*/
return 0;
}
pnc->last_update = pim_time_monotonic_sec ();
distance = stream_getc (s);
@ -644,4 +618,5 @@ pim_parse_nexthop_update (struct zclient *zclient, int command,
if (listcount (pnc->upstream_list))
pim_update_upstream_nh (pnc);
return 0;
}

View File

@ -48,8 +48,8 @@ struct pim_nexthop_cache
struct list *upstream_list;
};
void pim_parse_nexthop_update (struct zclient *zclient, int command,
vrf_id_t vrf_id);
int pim_parse_nexthop_update (int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id);
int pim_find_or_track_nexthop (struct prefix *addr, struct pim_upstream *up,
struct rp_info *rp);
void pim_delete_tracked_nexthop (struct prefix *addr, struct pim_upstream *up,

View File

@ -310,10 +310,8 @@ static int pim_sock_read(struct thread *t)
if (errno == EINTR)
continue;
if (errno == EWOULDBLOCK || errno == EAGAIN)
{
cont = 0;
break;
}
break;
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug ("Received errno: %d %s", errno, safe_strerror (errno));
goto done;

View File

@ -54,7 +54,7 @@ pim_register_join (struct pim_upstream *up)
{
if (PIM_DEBUG_PIM_EVENTS)
zlog_debug ("%s register setup skipped as group is SSM", up->sg_str);
return;
return;
}
pim_channel_add_oif (up->channel_oil, pim_regiface, PIM_OIF_FLAG_PROTO_PIM);

View File

@ -54,21 +54,12 @@ pim_rp_info_free (struct rp_info *rp_info)
XFREE (MTYPE_PIM_RP, rp_info);
}
static int
int
pim_rp_list_cmp (void *v1, void *v2)
{
struct rp_info *rp1 = (struct rp_info *)v1;
struct rp_info *rp2 = (struct rp_info *)v2;
if (rp1 == rp2)
return 0;
if (!rp1 && rp2)
return -1;
if (rp1 && !rp2)
return 1;
/*
* Sort by RP IP address
*/
@ -87,10 +78,7 @@ pim_rp_list_cmp (void *v1, void *v2)
if (rp1->group.u.prefix4.s_addr > rp2->group.u.prefix4.s_addr)
return 1;
if (rp1 == tail)
return 1;
return -1;
return 0;
}
void

View File

@ -61,4 +61,6 @@ struct pim_rpf *pim_rp_g (struct in_addr group);
#define RP(G) pim_rp_g ((G))
void pim_rp_show_information (struct vty *vty, u_char uj);
int pim_rp_list_cmp (void *v1, void *v2);
#endif

View File

@ -602,14 +602,6 @@ void sched_rpf_cache_refresh(void)
0, qpim_rpf_cache_refresh_delay_msec);
}
static int
pim_zebra_nexthop_update (int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id)
{
pim_parse_nexthop_update (zclient, command, vrf_id);
return 0;
}
static void
pim_zebra_connected (struct zclient *zclient)
{
@ -637,7 +629,7 @@ void pim_zebra_init(void)
zclient->interface_down = pim_zebra_if_state_down;
zclient->interface_address_add = pim_zebra_if_address_add;
zclient->interface_address_delete = pim_zebra_if_address_del;
zclient->nexthop_update = pim_zebra_nexthop_update;
zclient->nexthop_update = pim_parse_nexthop_update;
zclient_init(zclient, ZEBRA_ROUTE_PIM, 0);
if (PIM_DEBUG_PIM_TRACE) {

View File

@ -108,8 +108,14 @@ pim_vrf_enable (struct vrf *vrf)
{
pimg = pim_instance_init (VRF_DEFAULT, AFI_IP);
if (pimg == NULL)
zlog_err ("%s %s: pim class init failure ", __FILE__,
__PRETTY_FUNCTION__);
{
zlog_err ("%s %s: pim class init failure ", __FILE__,
__PRETTY_FUNCTION__);
/*
* We will crash and burn otherwise
*/
exit(1);
}
}
return 0;
}
@ -194,12 +200,18 @@ static void
pim_instance_terminate (void)
{
/* Traverse and cleanup rpf_hash */
if (pimg && pimg->rpf_hash)
if (pimg->rpf_hash)
{
hash_clean (pimg->rpf_hash, (void *) pim_rp_list_hash_clean);
hash_free (pimg->rpf_hash);
pimg->rpf_hash = NULL;
}
if (pimg->ssm_info)
{
pim_ssm_terminate (pimg->ssm_info);
pimg->ssm_info = NULL;
}
pim_ssm_terminate (pimg->ssm_info);
XFREE (MTYPE_PIM_PIM_INSTANCE, pimg);
}