Skip to content

Commit

Permalink
Merge pull request #6175 from ton31337/fix/avoid_same_type_typecasting
Browse files Browse the repository at this point in the history
*: Do not cast to the same type
  • Loading branch information
eqvinox authored Apr 8, 2020
2 parents c189a11 + ff8b039 commit 2ee1e4b
Show file tree
Hide file tree
Showing 48 changed files with 100 additions and 106 deletions.
2 changes: 1 addition & 1 deletion babeld/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ babel_send(int s,
iovec[1].iov_base = buf2;
iovec[1].iov_len = buflen2;
memset(&msg, 0, sizeof(msg));
msg.msg_name = (struct sockaddr*)sin;
msg.msg_name = sin;
msg.msg_namelen = slen;
msg.msg_iov = iovec;
msg.msg_iovlen = 2;
Expand Down
5 changes: 2 additions & 3 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2178,8 +2178,7 @@ bgp_attr_large_community(struct bgp_attr_parser_args *args)
args->total);
}

attr->lcommunity =
lcommunity_parse((uint8_t *)stream_pnt(peer->curr), length);
attr->lcommunity = lcommunity_parse(stream_pnt(peer->curr), length);
/* XXX: fix ecommunity_parse to use stream API */
stream_forward_getp(peer->curr, length);

Expand Down Expand Up @@ -2209,7 +2208,7 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
}

attr->ecommunity =
ecommunity_parse((uint8_t *)stream_pnt(peer->curr), length);
ecommunity_parse(stream_pnt(peer->curr), length);
/* XXX: fix ecommunity_parse to use stream API */
stream_forward_getp(peer->curr, length);

Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_community.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ char *community_str(struct community *com, bool make_json)
hash package.*/
unsigned int community_hash_make(const struct community *com)
{
uint32_t *pnt = (uint32_t *)com->val;
uint32_t *pnt = com->val;

return jhash2(pnt, com->size, 0x43ea96c1);
}
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_ecommunity.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
if (sub_type == ECOMMUNITY_REDIRECT_VRF) {
char buf[16] = {};
ecommunity_rt_soo_str(
buf, sizeof(buf), (uint8_t *)pnt,
buf, sizeof(buf), pnt,
type & ~ECOMMUNITY_ENCODE_TRANS_EXP,
ECOMMUNITY_ROUTE_TARGET,
ECOMMUNITY_FORMAT_DISPLAY);
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
if (type == ECOMMUNITY_ENCODE_EVPN
&& sub_type
== ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) {
ecom_val_ptr = (uint8_t *)(attr->ecommunity->val
+ (i * 8));
ecom_val_ptr =
(attr->ecommunity->val + (i * 8));
break;
}
}
Expand Down
5 changes: 2 additions & 3 deletions bgpd/bgp_evpn_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2515,8 +2515,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
return;
}

bgp_evpn_route2str((struct prefix_evpn *)&p, prefix_str,
sizeof(prefix_str));
bgp_evpn_route2str(&p, prefix_str, sizeof(prefix_str));

/* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, rn, prd, afi, safi, json);
Expand Down Expand Up @@ -2574,7 +2573,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
safi = SAFI_EVPN;
prefix_cnt = path_cnt = 0;

prefix_rd2str((struct prefix_rd *)prd, rd_str, sizeof(rd_str));
prefix_rd2str(prd, rd_str, sizeof(rd_str));

rd_rn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd);
if (!rd_rn)
Expand Down
3 changes: 1 addition & 2 deletions bgpd/bgp_nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,7 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)

bgp_address_del(bgp, ifc, addr);

rn = bgp_node_lookup(bgp->connected_table[AFI_IP6],
(struct prefix *)&p);
rn = bgp_node_lookup(bgp->connected_table[AFI_IP6], &p);
}

if (!rn)
Expand Down
7 changes: 3 additions & 4 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -8298,7 +8298,7 @@ void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
mac = ecom_mac2str((char *)routermac->val);
if (mac) {
if (!json_path) {
vty_out(vty, "/%s", (char *)mac);
vty_out(vty, "/%s", mac);
} else {
json_object_string_add(json_overlay, "rmac",
mac);
Expand Down Expand Up @@ -12268,7 +12268,7 @@ static int bgp_distance_set(struct vty *vty, const char *distance_str,
distance = atoi(distance_str);

/* Get BGP distance node. */
rn = bgp_node_get(bgp_distance_table[afi][safi], (struct prefix *)&p);
rn = bgp_node_get(bgp_distance_table[afi][safi], &p);
bdistance = bgp_node_get_bgp_distance_info(rn);
if (bdistance)
bgp_unlock_node(rn);
Expand Down Expand Up @@ -12309,8 +12309,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
return CMD_WARNING_CONFIG_FAILED;
}

rn = bgp_node_lookup(bgp_distance_table[afi][safi],
(struct prefix *)&p);
rn = bgp_node_lookup(bgp_distance_table[afi][safi], &p);
if (!rn) {
vty_out(vty, "Can't find specified prefix\n");
return CMD_WARNING_CONFIG_FAILED;
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static uint8_t *bgpVersion(struct variable *v, oid name[], size_t *length,

/* Return octet string length 1. */
*var_len = 1;
return (uint8_t *)&version;
return &version;
}

static uint8_t *bgpLocalAs(struct variable *v, oid name[], size_t *length,
Expand Down
3 changes: 1 addition & 2 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6173,8 +6173,7 @@ static void peer_aslist_update(const char *aslist_name)
static void peer_aslist_add(char *aslist_name)
{
peer_aslist_update(aslist_name);
route_map_notify_dependencies((char *)aslist_name,
RMAP_EVENT_ASLIST_ADDED);
route_map_notify_dependencies(aslist_name, RMAP_EVENT_ASLIST_ADDED);
}

static void peer_aslist_del(const char *aslist_name)
Expand Down
2 changes: 1 addition & 1 deletion bgpd/rfapi/rfapi_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch(

bpi_fake.peer = peer;
bpi_fake.extra = &bpi_extra;
bpi_fake.extra->vnc.import.rd = *(struct prefix_rd *)prd;
bpi_fake.extra->vnc.import.rd = *prd;
if (aux_prefix) {
bpi_fake.extra->vnc.import.aux_prefix = *aux_prefix;
} else {
Expand Down
5 changes: 2 additions & 3 deletions bgpd/rfapi/rfapi_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,9 @@ void rfapiMonitorItNodeChanged(
if ((sl = RFAPI_MONITOR_ETH(rn))) {

for (cursor = NULL,
rc = skiplist_next(sl, NULL, (void **)&m,
(void **)&cursor);
rc = skiplist_next(sl, NULL, (void **)&m, &cursor);
!rc; rc = skiplist_next(sl, NULL, (void **)&m,
(void **)&cursor)) {
&cursor)) {

if (skiplist_search(nves_seen, m->rfd, NULL)) {
/*
Expand Down
4 changes: 2 additions & 2 deletions bgpd/rfapi/rfapi_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ static void rfapi_info_free(struct rfapi_info *goner)
if (goner->timer) {
struct rfapi_rib_tcb *tcb;

tcb = ((struct thread *)goner->timer)->arg;
thread_cancel((struct thread *)goner->timer);
tcb = goner->timer->arg;
thread_cancel(goner->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
goner->timer = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion bgpd/rfapi/rfapi_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -3428,7 +3428,7 @@ static void clear_vnc_nve_closer(struct rfapi_local_reg_delete_arg *cda)
&cursor)) {

if (pValue->rfd) {
((struct rfapi_descriptor *)pValue->rfd)->flags |=
pValue->rfd->flags |=
RFAPI_HD_FLAG_CLOSING_ADMINISTRATIVELY;
rfapi_close(pValue->rfd);
}
Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
struct route_node *rn;
struct interface *ifp;

rn = route_node_get(eigrp->networks, (struct prefix *)p);
rn = route_node_get(eigrp->networks, p);
if (rn->info) {
/* There is already same network statement. */
route_unlock_node(rn);
Expand Down
2 changes: 1 addition & 1 deletion ldpd/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ sock_set_md5sig(int fd, int af, union ldpd_addr *addr, const char *password)
int
sock_set_ipv4_tos(int fd, int tos)
{
if (setsockopt(fd, IPPROTO_IP, IP_TOS, (int *)&tos, sizeof(tos)) < 0) {
if (setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) {
log_warn("%s: error setting IP_TOS to 0x%x", __func__, tos);
return (-1);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/command_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum matcher_rv command_match(struct graph *cmdgraph, vector vline,

// prepend a dummy token to match that pesky start node
vector vvline = vector_init(vline->alloced + 1);
vector_set_index(vvline, 0, (void *)XSTRDUP(MTYPE_TMP, "dummy"));
vector_set_index(vvline, 0, XSTRDUP(MTYPE_TMP, "dummy"));
memcpy(vvline->index + 1, vline->index,
sizeof(void *) * vline->alloced);
vvline->active = vline->active + 1;
Expand Down
4 changes: 2 additions & 2 deletions lib/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void hmac_md5(unsigned char *text, int text_len, unsigned char *key,
* pass */
MD5Update(&context, k_ipad, 64); /* start with inner pad */
MD5Update(&context, text, text_len); /* then text of datagram */
MD5Final((uint8_t *)digest, &context); /* finish up 1st pass */
MD5Final(digest, &context); /* finish up 1st pass */
/*
* perform outer MD5
*/
Expand All @@ -438,5 +438,5 @@ void hmac_md5(unsigned char *text, int text_len, unsigned char *key,
MD5Update(&context, k_opad, 64); /* start with outer pad */
MD5Update(&context, digest, 16); /* then results of 1st
* hash */
MD5Final((uint8_t *)digest, &context); /* finish up 2nd pass */
MD5Final(digest, &context); /* finish up 2nd pass */
}
4 changes: 2 additions & 2 deletions lib/skiplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void skiplist_test(struct vty *vty)
zlog_debug("%s: (%d:%d)", __func__, i, k);
}
// keys[k] = (void *)random();
keys[k] = (void *)scramble(k);
keys[k] = scramble(k);
if (skiplist_insert(l, keys[k], keys[k]))
zlog_debug("error in insert #%d,#%d", i, k);
}
Expand All @@ -649,7 +649,7 @@ void skiplist_test(struct vty *vty)
zlog_debug("<%d:%d>", i, k);
if (skiplist_delete(l, keys[k], keys[k]))
zlog_debug("error in delete");
keys[k] = (void *)scramble(k ^ 0xf0f0f0f0);
keys[k] = scramble(k ^ 0xf0f0f0f0);
if (skiplist_insert(l, keys[k], keys[k]))
zlog_debug("error in insert #%d,#%d", i, k);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static void route_common(const struct prefix *n, const struct prefix *p,
np = (const uint8_t *)&n->u.prefix;
pp = (const uint8_t *)&p->u.prefix;

newp = (uint8_t *)&new->u.prefix;
newp = &new->u.prefix;

for (i = 0; i < p->prefixlen / 8; i++) {
if (np[i] == pp[i])
Expand Down
2 changes: 1 addition & 1 deletion lib/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void vrf_update_vrf_id(ns_id_t ns_id, void *opaqueptr)
vrf->vrf_id = vrf_id;
RB_INSERT(vrf_id_head, &vrfs_by_id, vrf);
if (old_vrf_id == VRF_UNKNOWN)
vrf_enable((struct vrf *)vrf);
vrf_enable(vrf);
}

int vrf_switch_to_netns(vrf_id_t vrf_id)
Expand Down
2 changes: 1 addition & 1 deletion lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
stream_putc(s, api->prefix.family);
psize = PSIZE(api->prefix.prefixlen);
stream_putc(s, api->prefix.prefixlen);
stream_write(s, (uint8_t *)&api->prefix.u.prefix, psize);
stream_write(s, &api->prefix.u.prefix, psize);

if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {
psize = PSIZE(api->src_prefix.prefixlen);
Expand Down
8 changes: 4 additions & 4 deletions nhrpd/zbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ static inline void *__zbuf_pull(struct zbuf *zb, size_t size, int error)
}

#define zbuf_pull(zb, type) ((type *)__zbuf_pull(zb, sizeof(type), 1))
#define zbuf_pulln(zb, sz) ((void *)__zbuf_pull(zb, sz, 1))
#define zbuf_pulln(zb, sz) (__zbuf_pull(zb, sz, 1))
#define zbuf_may_pull(zb, type) ((type *)__zbuf_pull(zb, sizeof(type), 0))
#define zbuf_may_pulln(zb, sz) ((void *)__zbuf_pull(zb, sz, 0))
#define zbuf_may_pulln(zb, sz) (__zbuf_pull(zb, sz, 0))

void *zbuf_may_pull_until(struct zbuf *zb, const char *sep, struct zbuf *msg);

Expand Down Expand Up @@ -149,9 +149,9 @@ static inline void *__zbuf_push(struct zbuf *zb, size_t size, int error)
}

#define zbuf_push(zb, type) ((type *)__zbuf_push(zb, sizeof(type), 1))
#define zbuf_pushn(zb, sz) ((void *)__zbuf_push(zb, sz, 1))
#define zbuf_pushn(zb, sz) (__zbuf_push(zb, sz, 1))
#define zbuf_may_push(zb, type) ((type *)__zbuf_may_push(zb, sizeof(type), 0))
#define zbuf_may_pushn(zb, sz) ((void *)__zbuf_push(zb, sz, 0))
#define zbuf_may_pushn(zb, sz) (__zbuf_push(zb, sz, 0))

static inline void zbuf_put(struct zbuf *zb, const void *src, size_t len)
{
Expand Down
4 changes: 2 additions & 2 deletions ospf6d/ospf6_asbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,8 @@ void ospf6_asbr_distribute_list_update(int type)
ZROUTE_NAME(type));

ospf6->t_distribute_update = NULL;
thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer,
(void **)args, OSPF_MIN_LS_INTERVAL,
thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer, args,
OSPF_MIN_LS_INTERVAL,
&ospf6->t_distribute_update);
}

Expand Down
4 changes: 2 additions & 2 deletions ospf6d/ospf6_lsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header)
/* allocate memory */
lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));

lsa->header = (struct ospf6_lsa_header *)new_header;
lsa->header = new_header;

/* dump string */
ospf6_lsa_printbuf(lsa, lsa->name, sizeof(lsa->name));
Expand All @@ -554,7 +554,7 @@ struct ospf6_lsa *ospf6_lsa_create_headeronly(struct ospf6_lsa_header *header)
/* allocate memory */
lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));

lsa->header = (struct ospf6_lsa_header *)new_header;
lsa->header = new_header;
SET_FLAG(lsa->flag, OSPF6_LSA_HEADERONLY);

/* dump string */
Expand Down
6 changes: 3 additions & 3 deletions ospf6d/ospf6_spf.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
rtr_lsa = ospf6_lsdb_next(end, rtr_lsa);
continue;
}
lsa_header = (struct ospf6_lsa_header *)rtr_lsa->header;
lsa_header = rtr_lsa->header;
total_lsa_length += (ntohs(lsa_header->length) - lsa_length);
num_lsa++;
rtr_lsa = ospf6_lsdb_next(end, rtr_lsa);
Expand Down Expand Up @@ -1027,7 +1027,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
assert(rtr_lsa);
if (!OSPF6_LSA_IS_MAXAGE(rtr_lsa)) {
/* Append first Link State ID LSA */
lsa_header = (struct ospf6_lsa_header *)rtr_lsa->header;
lsa_header = rtr_lsa->header;
memcpy(new_header, lsa_header, ntohs(lsa_header->length));
/* Assign new lsa length as aggregated length. */
((struct ospf6_lsa_header *)new_header)->length =
Expand Down Expand Up @@ -1057,7 +1057,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
}

/* Append Next Link State ID LSA */
lsa_header = (struct ospf6_lsa_header *)rtr_lsa->header;
lsa_header = rtr_lsa->header;
memcpy(new_header, (OSPF6_LSA_HEADER_END(rtr_lsa->header) + 4),
(ntohs(lsa_header->length) - lsa_length));
new_header += (ntohs(lsa_header->length) - lsa_length);
Expand Down
4 changes: 2 additions & 2 deletions ospf6d/ospf6_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)

if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
char prefixstr[PREFIX2STR_BUFFER], nexthopstr[128];
prefix2str((struct prefix *)&api.prefix, prefixstr,
sizeof(prefixstr));

prefix2str(&api.prefix, prefixstr, sizeof(prefixstr));
inet_ntop(AF_INET6, nexthop, nexthopstr, sizeof(nexthopstr));

zlog_debug(
Expand Down
6 changes: 2 additions & 4 deletions ospfd/ospf_abr.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,7 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
else
full_cost = cost;

old = ospf_lsa_lookup_by_prefix(area->lsdb, OSPF_SUMMARY_LSA,
(struct prefix_ipv4 *)p,
old = ospf_lsa_lookup_by_prefix(area->lsdb, OSPF_SUMMARY_LSA, p,
area->ospf->router_id);
if (old) {
if (IS_DEBUG_OSPF_EVENT)
Expand Down Expand Up @@ -761,8 +760,7 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
zlog_debug(
"ospf_abr_announce_network_to_area(): "
"creating new summary");
lsa = ospf_summary_lsa_originate((struct prefix_ipv4 *)p,
full_cost, area);
lsa = ospf_summary_lsa_originate(p, full_cost, area);
/* This will flood through area. */

if (!lsa) {
Expand Down
4 changes: 2 additions & 2 deletions ospfd/ospf_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ static uint16_t show_vty_link_info(struct vty *vty, struct tlv_header *ext)
/* Extended Link TLVs */
static void ospf_ext_link_show_info(struct vty *vty, struct ospf_lsa *lsa)
{
struct lsa_header *lsah = (struct lsa_header *)lsa->data;
struct lsa_header *lsah = lsa->data;
struct tlv_header *tlvh;
uint16_t length = 0, sum = 0;

Expand Down Expand Up @@ -1758,7 +1758,7 @@ static uint16_t show_vty_pref_info(struct vty *vty, struct tlv_header *ext)
/* Extended Prefix TLVs */
static void ospf_ext_pref_show_info(struct vty *vty, struct ospf_lsa *lsa)
{
struct lsa_header *lsah = (struct lsa_header *)lsa->data;
struct lsa_header *lsah = lsa->data;
struct tlv_header *tlvh;
uint16_t length = 0, sum = 0;

Expand Down
Loading

0 comments on commit 2ee1e4b

Please sign in to comment.