From 9f5dc3192ed5325b39bdb0580700652b06440606 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 25 Feb 2019 20:30:31 +0000 Subject: [PATCH] *: remove casts of XMALLOC / XCALLOC No cast necessary for void * Signed-off-by: Quentin Young --- bgpd/bgp_advertise.c | 7 +++---- bgpd/bgp_attr_evpn.c | 4 ++-- bgpd/bgp_community.c | 3 +-- bgpd/bgp_ecommunity.c | 3 +-- bgpd/bgp_lcommunity.c | 3 +-- bgpd/bgp_updgrp_packet.c | 3 +-- bgpd/bgp_zebra.c | 3 +-- bgpd/bgpd.c | 3 +-- bgpd/rfapi/bgp_rfapi_cfg.c | 3 +-- bgpd/rfapi/rfapi_import.c | 2 +- lib/filter.c | 6 ++---- lib/prefix.c | 6 ++---- ospf6d/ospf6_interface.c | 3 +-- ospf6d/ospf6_lsa.c | 13 +++++-------- ospf6d/ospf6_neighbor.c | 3 +-- ospf6d/ospf6_spf.c | 6 ++---- ospfd/ospf_asbr.c | 3 +-- ospfd/ospf_zebra.c | 6 ++---- 18 files changed, 29 insertions(+), 51 deletions(-) diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c index 93094b76d9..05eeeca156 100644 --- a/bgpd/bgp_advertise.c +++ b/bgpd/bgp_advertise.c @@ -45,8 +45,8 @@ peer. */ struct bgp_advertise_attr *baa_new(void) { - return (struct bgp_advertise_attr *)XCALLOC( - MTYPE_BGP_ADVERTISE_ATTR, sizeof(struct bgp_advertise_attr)); + return XCALLOC(MTYPE_BGP_ADVERTISE_ATTR, + sizeof(struct bgp_advertise_attr)); } static void baa_free(struct bgp_advertise_attr *baa) @@ -84,8 +84,7 @@ bool baa_hash_cmp(const void *p1, const void *p2) information. */ struct bgp_advertise *bgp_advertise_new(void) { - return (struct bgp_advertise *)XCALLOC(MTYPE_BGP_ADVERTISE, - sizeof(struct bgp_advertise)); + return XCALLOC(MTYPE_BGP_ADVERTISE, sizeof(struct bgp_advertise)); } void bgp_advertise_free(struct bgp_advertise *adv) diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index 3e9d05ad97..ca04ebf550 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -84,8 +84,8 @@ char *esi2str(struct eth_segment_id *id) return NULL; val = id->val; - ptr = (char *)XMALLOC(MTYPE_TMP, - (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char)); + ptr = XMALLOC(MTYPE_TMP, + (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char)); snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1), "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", val[0], diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index 040fcabbe6..d3c5a8ef14 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -34,8 +34,7 @@ static struct hash *comhash; /* Allocate a new communities value. */ static struct community *community_new(void) { - return (struct community *)XCALLOC(MTYPE_COMMUNITY, - sizeof(struct community)); + return XCALLOC(MTYPE_COMMUNITY, sizeof(struct community)); } /* Free communities value. */ diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 7f58622572..2a8d27ba24 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -48,8 +48,7 @@ static struct hash *ecomhash; /* Allocate a new ecommunities. */ struct ecommunity *ecommunity_new(void) { - return (struct ecommunity *)XCALLOC(MTYPE_ECOMMUNITY, - sizeof(struct ecommunity)); + return XCALLOC(MTYPE_ECOMMUNITY, sizeof(struct ecommunity)); } void ecommunity_strfree(char **s) diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index fcf2a3b57c..edc364ec27 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -38,8 +38,7 @@ static struct hash *lcomhash; /* Allocate a new lcommunities. */ static struct lcommunity *lcommunity_new(void) { - return (struct lcommunity *)XCALLOC(MTYPE_LCOMMUNITY, - sizeof(struct lcommunity)); + return XCALLOC(MTYPE_LCOMMUNITY, sizeof(struct lcommunity)); } /* Allocate lcommunities. */ diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index cbbf8b2302..66e306cba2 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -69,8 +69,7 @@ struct bpacket *bpacket_alloc(void) { struct bpacket *pkt; - pkt = (struct bpacket *)XCALLOC(MTYPE_BGP_PACKET, - sizeof(struct bpacket)); + pkt = XCALLOC(MTYPE_BGP_PACKET, sizeof(struct bpacket)); return pkt; } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 82a0003928..1df5f642b3 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1573,8 +1573,7 @@ struct bgp_redist *bgp_redist_add(struct bgp *bgp, afi_t afi, uint8_t type, bgp->redist[afi][type] = list_new(); red_list = bgp->redist[afi][type]; - red = (struct bgp_redist *)XCALLOC(MTYPE_BGP_REDIST, - sizeof(struct bgp_redist)); + red = XCALLOC(MTYPE_BGP_REDIST, sizeof(struct bgp_redist)); red->instance = instance; listnode_add(red_list, red); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index ab4aab8ae0..8e397f0c0e 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -2379,8 +2379,7 @@ static int peer_group_cmp(struct peer_group *g1, struct peer_group *g2) /* Peer group cofiguration. */ static struct peer_group *peer_group_new(void) { - return (struct peer_group *)XCALLOC(MTYPE_PEER_GROUP, - sizeof(struct peer_group)); + return XCALLOC(MTYPE_PEER_GROUP, sizeof(struct peer_group)); } static void peer_group_free(struct peer_group *group) diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 53957d51b4..2220f0ed9a 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -3814,8 +3814,7 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg) struct rfapi_cfg *h; afi_t afi; - h = (struct rfapi_cfg *)XCALLOC(MTYPE_RFAPI_CFG, - sizeof(struct rfapi_cfg)); + h = XCALLOC(MTYPE_RFAPI_CFG, sizeof(struct rfapi_cfg)); assert(h); h->nve_groups_sequential = list_new(); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 6b37073e0e..55775f384f 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -4285,7 +4285,7 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp) assert(bgp->rfapi_cfg == NULL); - h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi)); + h = XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi)); for (afi = AFI_IP; afi < AFI_MAX; afi++) { h->un[afi] = agg_table_init(); diff --git a/lib/filter.c b/lib/filter.c index 7df384f3b5..276df4b4d7 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -128,8 +128,7 @@ static struct access_master *access_master_get(afi_t afi) /* Allocate new filter structure. */ static struct filter *filter_new(void) { - return (struct filter *)XCALLOC(MTYPE_ACCESS_FILTER, - sizeof(struct filter)); + return XCALLOC(MTYPE_ACCESS_FILTER, sizeof(struct filter)); } static void filter_free(struct filter *filter) @@ -202,8 +201,7 @@ static int filter_match_zebra(struct filter *mfilter, const struct prefix *p) /* Allocate new access list structure. */ static struct access_list *access_list_new(void) { - return (struct access_list *)XCALLOC(MTYPE_ACCESS_LIST, - sizeof(struct access_list)); + return XCALLOC(MTYPE_ACCESS_LIST, sizeof(struct access_list)); } /* Free allocated access_list. */ diff --git a/lib/prefix.c b/lib/prefix.c index 72ae0e635c..365a9ba38f 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1502,8 +1502,7 @@ char *prefix_mac2str(const struct ethaddr *mac, char *buf, int size) if (!mac) return NULL; if (!buf) - ptr = (char *)XMALLOC(MTYPE_TMP, - ETHER_ADDR_STRLEN * sizeof(char)); + ptr = XMALLOC(MTYPE_TMP, ETHER_ADDR_STRLEN * sizeof(char)); else { assert(size >= ETHER_ADDR_STRLEN); ptr = buf; @@ -1584,8 +1583,7 @@ char *esi_to_str(const esi_t *esi, char *buf, int size) if (!esi) return NULL; if (!buf) - ptr = (char *)XMALLOC(MTYPE_TMP, - ESI_STR_LEN * sizeof(char)); + ptr = XMALLOC(MTYPE_TMP, ESI_STR_LEN * sizeof(char)); else { assert(size >= ESI_STR_LEN); ptr = buf; diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 83b9001fea..692c84ad08 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -177,8 +177,7 @@ struct ospf6_interface *ospf6_interface_create(struct interface *ifp) struct ospf6_interface *oi; unsigned int iobuflen; - oi = (struct ospf6_interface *)XCALLOC(MTYPE_OSPF6_IF, - sizeof(struct ospf6_interface)); + oi = XCALLOC(MTYPE_OSPF6_IF, sizeof(struct ospf6_interface)); oi->area = (struct ospf6_area *)NULL; oi->neighbor_list = list_new(); diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index 40b3522c3d..9acbd09b1a 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -518,16 +518,14 @@ struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header) lsa_size = ntohs(header->length); /* XXX vulnerable */ /* allocate memory for this LSA */ - new_header = (struct ospf6_lsa_header *)XMALLOC(MTYPE_OSPF6_LSA_HEADER, - lsa_size); + new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, lsa_size); /* copy LSA from original header */ memcpy(new_header, header, lsa_size); /* LSA information structure */ /* allocate memory */ - lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA, - sizeof(struct ospf6_lsa)); + lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa)); lsa->header = (struct ospf6_lsa_header *)new_header; @@ -546,16 +544,15 @@ struct ospf6_lsa *ospf6_lsa_create_headeronly(struct ospf6_lsa_header *header) struct ospf6_lsa_header *new_header = NULL; /* allocate memory for this LSA */ - new_header = (struct ospf6_lsa_header *)XMALLOC( - MTYPE_OSPF6_LSA_HEADER, sizeof(struct ospf6_lsa_header)); + new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, + sizeof(struct ospf6_lsa_header)); /* copy LSA from original header */ memcpy(new_header, header, sizeof(struct ospf6_lsa_header)); /* LSA information structure */ /* allocate memory */ - lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA, - sizeof(struct ospf6_lsa)); + lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa)); lsa->header = (struct ospf6_lsa_header *)new_header; SET_FLAG(lsa->flag, OSPF6_LSA_HEADERONLY); diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index bb451c239e..8a9c2626b0 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -86,8 +86,7 @@ struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id, struct ospf6_neighbor *on; char buf[16]; - on = (struct ospf6_neighbor *)XMALLOC(MTYPE_OSPF6_NEIGHBOR, - sizeof(struct ospf6_neighbor)); + on = XMALLOC(MTYPE_OSPF6_NEIGHBOR, sizeof(struct ospf6_neighbor)); memset(on, 0, sizeof(struct ospf6_neighbor)); inet_ntop(AF_INET, &router_id, buf, sizeof(buf)); diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 2d271c1dab..d4f6f6f4ae 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -107,8 +107,7 @@ static struct ospf6_vertex *ospf6_vertex_create(struct ospf6_lsa *lsa) { struct ospf6_vertex *v; - v = (struct ospf6_vertex *)XMALLOC(MTYPE_OSPF6_VERTEX, - sizeof(struct ospf6_vertex)); + v = XMALLOC(MTYPE_OSPF6_VERTEX, sizeof(struct ospf6_vertex)); /* type */ if (ntohs(lsa->header->type) == OSPF6_LSTYPE_ROUTER) { @@ -1016,8 +1015,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area, new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, total_lsa_length); /* LSA information structure */ - lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA, - sizeof(struct ospf6_lsa)); + lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa)); lsa->header = (struct ospf6_lsa_header *)new_header; diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index ba2e04bf76..ea919017d3 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -79,8 +79,7 @@ struct external_info *ospf_external_info_new(uint8_t type, { struct external_info *new; - new = (struct external_info *)XCALLOC(MTYPE_OSPF_EXTERNAL_INFO, - sizeof(struct external_info)); + new = XCALLOC(MTYPE_OSPF_EXTERNAL_INFO, sizeof(struct external_info)); new->type = type; new->instance = instance; diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index ea2c492e18..4cbd817ad8 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -560,8 +560,7 @@ struct ospf_external *ospf_external_add(struct ospf *ospf, uint8_t type, ospf->external[type] = list_new(); ext_list = ospf->external[type]; - ext = (struct ospf_external *)XCALLOC(MTYPE_OSPF_EXTERNAL, - sizeof(struct ospf_external)); + ext = XCALLOC(MTYPE_OSPF_EXTERNAL, sizeof(struct ospf_external)); ext->instance = instance; EXTERNAL_INFO(ext) = route_table_init(); @@ -621,8 +620,7 @@ struct ospf_redist *ospf_redist_add(struct ospf *ospf, uint8_t type, ospf->redist[type] = list_new(); red_list = ospf->redist[type]; - red = (struct ospf_redist *)XCALLOC(MTYPE_OSPF_REDISTRIBUTE, - sizeof(struct ospf_redist)); + red = XCALLOC(MTYPE_OSPF_REDISTRIBUTE, sizeof(struct ospf_redist)); red->instance = instance; red->dmetric.type = -1; red->dmetric.value = -1; -- 2.39.5